While you can code your application pages using NotePad or any HTML editor, this book uses ColdFusion Studio because it provides many features that make ColdFusion development easier. You should install ColdFusion Studio if you have not done so already.
From a coding perspective, the major difference between a static HTML page and a ColdFusion application page is that ColdFusion pages contain ColdFusion Markup Language (CFML). CFML is a markup language that is 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, CFML identifies specific operations that are performed by ColdFusion Server.
The following procedure creates a simple ColdFusion Application page, which you use for other examples in this chapter.
<html> <head> <title>Call Department</title> </head> <body> <strong>Call Department</strong><br> <!--- Set all variables ---> <cfset department="Sales"> <!--- Display results ---> <cfoutput> I'd like to talk to someone in #Department#. </cfoutput> </body> </html>
Instead of saving pages with an htm or html file extension, you save ColdFusion application pages with a cfm or cfml extension. By default, the Web server knows to pass a page that contains a cfm extension to the ColdFusion Server when it is requested by a browser.
Save ColdFusion application pages underneath the Web root or another Web server mapping so that the Web server can publish these pages to the Internet. For example, you can create a directory myapps
and save your practice pages there.
For example, the directory path on your machine might be:
(on Windows NT) c:\inetpub\wwwroot\myapps
(on UNIX) <mywebserverdocroot>/myapps
You view the application page on the Web server to ensure that the code is working as expected. Presently, your page is very simple. But, as you add more code, you will want to ensure that the page continues to work.
http://127.0.0.1/myapps/calldept.cfm
where 127.0.0.1 refers to the localhost and is only valid when you are viewing pages locally.
Note that only HTML and text is returned to the browser.
Compare the code that was returned to the browser with what you originally created. Notice that the ColdFusion comments and CFML tags are processed, but do not appear in the HTML file that is returned to the browser.
The application page that you just created contains both HTML and CFML. You used the CFML tag cfset
to define a variable, Department, and set its value to "Sales." You then used the CFML tag cfoutput
to display text and the value of the variable. The following table describes the code and its function: