To write a ColdFusion application, you can use virtually any text editor or an HTML authoring tool that allows you to directly edit the code. As we discussed in Chapter 1, a ColdFusion application is a collection of web pages, also called templates or pages that work together to allow a user to perform a task. When you create a CFML template, you typically embed the CFML code within standard HTML (although it is also possible to create files that contain only CFML, as you’ll see later in the chapter). A ColdFusion application can be as simple as a single page. Consider the following example, which outputs the current date to the browser:
<html> <head> <title>CFML Example</title> </head> <body> <cfoutput> <h2>Today's date is #DateFormat(Now( ),'mm/dd/yyyy')#</h2> </cfoutput> </body> </html>
At first glance, this template looks just like an HTML template. If
you look closer, however, you’ll see embedded CFML
code right in the middle of the template. The code here uses a single
<cfoutput>) and two functions
DateFormat( ) and
Now( )) to
output the current date to the browser. We’ll get to
what this tag and the functions do in a bit. For now,
we’re just concerned with running the template and
understanding how CFML and HTML coexist.
To execute this template, you need to save the file on the machine that is running your web server and the ColdFusion Application Server. You can either type in this example and save it to a file or you can ...