Getting Started

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 tag (<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.

Saving CFML Templates

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 ...

Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.