• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Lesson 2. Introducing ColdFusion Studio > Creating Your First ColdFusion Page

Creating Your First ColdFusion Page

Now that you know your way around ColdFusion Studio, it's time to put that knowledge to use and create your first ColdFusion Page. You won't be doing anything fancy this time around, just a very basic page. It has become something of a tradition that when learning a new programming language the first thing you do is output “Hello World!” You will be doing just that. OK, you probably wouldn't be putting that on your commercial Web site, but it's a good way of getting started, and makes you a member of the programmers' club.

Choose File > New and select Default Template from the New Document window.

A new default template appears. This template already has the basic tags for an HTML document built into it, so you do not have to worry about adding them.


You can also create a new default template by pressing Ctrl+N.

Add the following code to the body of the document:

<cfoutput>Hello World!</cfoutput> 

The <cfoutput> tag in ColdFusion is one of its most important tools. Anything that is put between a set of <cfoutput> tags will be output by the ColdFusion server. It doesn't matter what is between those tags; whether it is plain HTML text or a ColdFusion variable, it's all handled by the ColdFusion server.

Click File > Save and browse to C:\Inetpub\wwwroot. Create a subfolder called lesson1.

Where you save your files is very important. In order for you to be able to view your files in a browser you must save them in the Inetpub\wwwroot folder, or a subfolder of the Inetpub\wwwroot folder.

Type helloworld.cfm into the File Name field and click Save.

You have now created your first ColdFusion page. Now you'll see what it does.


You can also press Ctrl+S to save your ColdFusion files.

Open a browser and type into the address field. Press Return.

You should see “Hello World!” displayed in the browser.

Click View > Source.

If you're using Navigator, choose View > Page Source.

As you can see, the <cfoutput> tags are gone. All that remains is “Hello World!” ColdFusion has taken the information between the <cfoutput> tags, processed it, and returned the corresponding HTML. This would look identical to the source if you had typed “Hello World!” without using the <cfoutput> tags. The big difference is the fact that, using the tags, you could change the variable value without having to change the HTML. For example, if you had a page with the name Kevin output in several places in plain HTML, you would have to change every instance of Kevin separately. If Kevin is a ColdFusion variable, all you'd have to do is change the value of the variable once and it is changed everywhere. You can see how this can be a big timesaver.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint