Listing 1

<!--- Write an HTML file to disk using CFFILE --->
<CFSAVECONTENT VARIABLE="myHtmlCode">
<html>
<head><title>A CFFILE example</title></head>
<body>
<h2>Hello World!</h2>
</body>
</html>
</CFSAVECONTENT>

<CFFILE ACTION="write" FILE="C:\Inetpub\wwwroot\mySite\myCreatedFile.html"
OUTPUT="#myHTMLCode#">

Listing 2

<!--- Include dynamic content in a file written to disk with CFFILE --->
<CFSAVECONTENT VARIABLE="myHtmlCode">
<html>
<head><title>A CFFILE example</title></head>
<body>
<CFOUTPUT>
<h2>Hello World, the date is #DateFormat(Now(), "m/d/yy")#!</h2>
</CFOUTPUT>
</body>
</html>
</CFSAVECONTENT>

<CFFILE ACTION="write" FILE="C:\Inetpub\wwwroot\mySite\myCreatedFile.html"
OUTPUT="#myHtmlCode#">

Listing 3

<!--- Create 700+ unique "details" pages from the database data --->
<CFQUERY NAME="listAllRecords" DATASOURCE="myProjects">
SELECT projectid, projectname, projectdesc, lastmodified
FROM projects
</CFQUERY>

<CFLOOP QUERY="listAllRecords">
<CFSAVECONTENT VARIABLE="myHtmlCode">
<html>
<head><title>Project Details</title></head>
<body>
<CFOUTPUT>
<h4>Project Details</h4>
<!--- "projectid" is an automatically incremented integer (& primary key) generated by the database --->
<p>Project ID: #listAllRecords.projectid#</p>
<p>Project Name: #listAllRecords.projectname#</p>
<p>Project Description: #Trim(listAllRecords.projectdesc)#</p>
<p>Last Modified: #DateFormat(listAllRecords.lastmodified, "mm/dd/yy")#</p>
</CFOUTPUT>
</body>
</html>
</CFSAVECONTENT>

<CFFILE ACTION="WRITE" FILE="C:\Inetpub\wwwroot\myProject\files\p#listAllRecords.projectid#.html"
OUTPUT="#myHtmlCode#">

</CFLOOP>

Listing 4

<!--- Create the "master" static Web page with a link to each "details" page --->
<CFQUERY NAME="listAllRecords" DATASOURCE="myProjects">
SELECT projectid, projectname, lastmodified
FROM projects
<!--- for demo, limit the query to Region 3 records only --->
WHERE region = 3
ORDER BY projectid
</CFQUERY>

<CFSAVECONTENT variable="pageContent">
<html>
<head><title>Master Project List for EPA Region 3</title></head>
<body>
<h4>Master Project List for EPA Region 3</h4>
<table cellpadding="2" border="1">
<tr>
  <th>Project ID</th>
  <th>Project Name</th>
  <th>Last Modified Date</th>
</tr>
<CFOUTPUT QUERY="listAllRecords">
<tr>
  <!--- Create a link to each "details" page using projectid parameter--->
  <td><a href="p#projectid#.html">#projectid#</a></td>
  <td>#projectname#</td>
  <td>#DateFormat(lastmodified, "mm/dd/yy")#</td>
</tr>
</CFOUTPUT>
</table>
</body>
</html>
</CFSAVECONTENT>

<CFFILE ACTION="write" FILE="C:\Inetpub\wwwroot\myProject\files\masterpage.html"
		OUTPUT="#pageContent#">

Listing 5

<CFQUERY NAME="listAllRecords" DATASOURCE="myProjects">
SELECT *
FROM projects
</CFQUERY>

<CFLOOP QUERY="listAllRecords">
<CFDOCUMENT FORMAT="PDF" FILENAME="C:\Inetpub\wwwroot\myProject\files\p#listAllRecords.projectid#.pdf"
OVERWRITE="yes">
<html>
<head><title>Project Details</title></head>
<body>
<h4>Project Details</h4>
<CFOUTPUT>
<p>Project ID: #listAllRecords.projectid#</p>
<p>Project Name: #listAllRecords.projectname#</p>
<p>Project Description: #Trim(listAllRecords.projectdesc)#</p>
<p>Last Modified: #DateFormat(listAllRecords.lastmodified, "mm/dd/yy")#</p>
</CFOUTPUT>
</body>
</html>
</CFDOCUMENT>
</CFLOOP>