Adding CFML

From a coding perspective, the major difference between a static HTML page and a ColdFusion application page is that ColdFusion pages contain an additional language, CFML.

CFML is a markup language that's very similar in syntax to HTML so Web developers find it intuitive.

Unlike HTML which defines how things are displayed and formatted on the client, each CFML tag identifies a specific operation that is performed on ColdFusion Server.

During this chapter, you will mix CFML with HTML to see, firsthand, how CFML is processed on the server. In subsequent chapters, you will learn how you to use CFML to perform specific server-side processing.

Note To add CFML to your page:
  1. Return to MyFirstPage.cfm in Allaire HomeSite.
  2. Below the BODY tag, add the following code:
  3. <CFSET ProductName="ColdFusion">
    

    You use the CFSET tag to initialize variables with a value.

    You will learn more about CFSET in the next chapter.

  4. Below the CFSET tag, add the following code:
  5. <CFOUTPUT>
    The product name is #ProductName#.
    </CFOUTPUT>
    

    You use the CFOUTPUT tag to output ColdFusion values to a page.

    You will learn more about CFOUTPUT in the next chapter.

  6. Save the page.
  7. Your code should look like this:

    <HTML>
    <HEAD>
    <TITLE>My First Page</TITLE>
    </HEAD>
    <BODY>
    <STRONG>ColdFusion</STRONG>
    <CFSET ProductName="ColdFusion">
    <CFOUTPUT>
    The product name is #ProductName#.
    </CFOUTPUT>
    </BODY>
    </HTML>
    
  8. Open a browser window.
  9. Enter this URL to view the page in the browser:
  10. http://127.0.0.1/CFDOCS/MyFirstPage.cfm
    

    "The product name is ColdFusion." appears below ColdFusion in the browser.

  11. View the source code in the browser.
  12. ColdFusion Server processes the CFSET and CFOUTPUT tags and returns HTML to the browser.

Click here to see how the file should look in a browser.

Click here to see the code behind the scenes.

You have created a ColdFusion application page that includes HTML and CFML and have followed the ColdFusion development process. Move on in this chapter to learn about other development considerations.