Introduction to ColdFusion

CFML is a tag-based server-side language. That means that writing it is similar to writing XHTML, but that it cannot be viewed locally through a browser. You need to either

 

The Code

As we said, CFML is a markup language (ML) that's very similar in syntax to XHTML. The difference in functionality is that CFML defines operations (think of it as a dynamic command language) whereas XHTML defines content, format and appearance.

To create a ColdFusion application page:

1. Open Notepad or any other text editor, or use Dreamweaver.

2. Select File --> New.

3. Set up a basic HTML page (this is the test file already in assignment1 on the assignment page):

<html> <head> <title>ColdFusion Server Test</title> </head>

<body> <!--- This is a coldFusion comment. Note the three hyphens --->
This is to test ColdFusion Installation. If you can see the current date, your ColdFusion server is installed successfully! <br> <CFSET dayToday=DateFormat(Now(), 'mmmm d, yyyy')> <cfoutput>#dayToday#</cfoutput>

</body> </html>

File extensions

Instead of an HTM or HTML file extension, ColdFusion file have CFM or CFML extension. The Web server or emulator knows to pass a page that contains a CFM extension to the ColdFusion Server when a browser requests it.

You need to save ColdFusion pages in the Web root folder or another Web server so that the Web server can interpret the pages. Create a unique directory, e.g., jb430 and save your test pages there.

For us, the local path to that folder would be C:\CFusionMX8\wwwroot if we were using the local emulator from CFMX8.
The directory path on some machines could be:
c:/inetpub/wwwroot/jb430 on Windows 2000, XP

Viewing files


To view the page either use a local browser:
1. Open a Web browser on your local machine and enter the following URL:
http://localhost:8500/jb430/test.cfm (Note the port number, could be :8501. You'll probably see that on other systems.)

OR (this semester) open it at:
http://csc-srv1.lasalle.edu/lastname/xx430/file.cfm
(note the student directory or a tilde ~ are not needed to view the file).

2. View source. You'll see that only HTML and text are 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's returned to the browser.

Next task

Note the test page used the CFML tag <cfset> to define a date variable from one of the many CFML pre-exisiting methods (objects). It is then output using a <cfoutput> element. How is the variable named in the <cfoutput> element?

You need to use the same process to creae a variable. Call it "name", and set its value to be "Your name", whatever that is, and then use a <cfoutput> element to display the value of that variable, in addtion to the date.

Variables

You can define your own variables. Remember

Back to home page