The i-Technology Media!
Register | Log in
   
 
.NET  ·  AJAX  ·  CLOUD  ·  ECLIPSE  ·  FLEX  ·  OPEN WEB  ·  iPHONE  ·  JAVA  ·  LINUX  ·  OPEN SOURCE  ·  ORACLE  ·  PBDJ  ·  SEARCH  ·  SILVERLIGHT  ·  SOA  ·  VIRTUALIZATION  ·  WEB 2.0  ·  WIRELESS  ·  XML
Comments
Drool, Britannia? Is the UK Failing the Cloud?
By Roger Strukhoff
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Jan. 8, 2012 11:38 AM EST
read more & respond »
Cloud Expo on Google News
Did you read today's front page stories & breaking news?

Cloud Expo & Virtualization 2011 West
Keynotes
Oracle
Opening Keynote | An Enterprise Cloud for Business-Critical Applications
Abiquo
Day 2 Keynote | The Enterprise Cloud Tightrope - Balancing for Success
Akamai
Day 3 Keynote | The DNA of an Enterprise Cloud
DIAMOND SPONSOR:
Oracle
Many Clouds, Many Choices'Cloud
PLATINUM PLUS SPONSORS:
Abiquo
Enterprise Cloud Best Practices - Town Hall - Join the discussion…
PLATINUM SPONSORS:
Intel
Progressing Toward the Federated, Automated and Client-Aware Cloud
New Relic
How to build an app with Twitter-like throughput
Rackspace
Computing in the Cloud Era
GOLD SPONSORS:
Gale Technologies
Practical Cloud Migration
IBM
Re-think IT. Re-inventing Business.
Intel/McAfee
Identity Driven Security in the Cloud
PerspecSys
Hackers Hackers Everywhere, Is My Public Cloud That Safe?
Red Hat
Unlock the Value of the Cloud
SHI
Mission Critical Applications and the Cloud - Myth or Reality?
SoftLayer
Not Your Grandpa's Cloud
Terremark
Integrating Enterprise Clouds
VMware
Upgrade to a vCloud
POWER PANELS:
Cloud Expo Silicon Valley: CTO Power Panel
Cloud Expo Silicon Valley: CEO Power Panel
Cloud Expo Silicon Valley: Cloud SuperStars Panel
Cloud Expo Silicon Valley: CloudNOW Panel
Click For 2010 West
Event Webcasts
Cloud Expo & Virtualization 2011 East
DIAMOND SPONSOR:
Dell
Dell & VMware Deliver the Enterprise Hybrid Cloud
PLATINUM PLUS SPONSORS:
Abiquo
Are Financial Services Organizations Risking Security by Avoiding Cloud Computing?
Oracle
From Consolidation to Enterprise Private PaaS
PLATINUM SPONSORS:
Intel
Driving the Transformation to Next Generation Cloud Data Centers
Rackspace
The Inevitability of an Open Cloud
GOLD SPONSORS:
CA Technologies
Follow YOUR path to Cloud Computing
Interxion
Who Keeps the Cloud in the Air?
Microsoft
Patterns for Cloud Computing
PerspecSys
War in the Clouds: Are you ready?
ServiceMesh
The Big Win: Stop Playing Small-Ball with Your Cloud Strategy
Terremark
Evaluating Enterprise Clouds
Xiotech
Cloud Storage: Myths and Realities
POWER PANELS:
Cloud Expo New York: CTO Power Panel
Cloud Expo New York: CEO Power Panel
Cloud Expo New York: CMO Power Panel
Cloud Expo New York: Wrap-Up Power Panel
Click For 2010 West
Event Webcasts
Live Google News by SYS-CON!
Top Three Links You Must Click On


CF Basics
Creating Dynamic Websites With ColdFusion
The CF Apprentice Series - Part 1: What is ColdFusion?

By: Michael Smith
Sep. 16, 2003 12:00 AM

Editor's Note: With so many new programmers getting interested in ColdFusion, CF Advisor felt it was time to have more articles addressing the concerns of beginning programmers in ColdFusion, much as we had in Leon Chalnick's Essentials column last year. Michael Smith, the president of TeraTech, who addresses the needs of beginners as part of his work for the Capitol PC User Group in Washington, DC, provided us with this, the first in a new series for beginners.

What is ColdFusion?
In this article we explore what ColdFusion is and what it can do for dynamic website creation. We will do some basic ColdFusion code examples to get you familiar with the language, and then we will discuss how a ColdFusion program works. We will also be covering where you can learn more about ColdFusion.

ColdFusion is a programming language based on standard HTML (Hyper Text Markup Language) that is used to write dynamic webpages. It lets you create pages on the fly that differ depending on user input, database lookups, time of day or whatever other criteria you dream up! ColdFusion pages consist of standard HTML tags such as <FONT SIZE="+2">, together with CFML (ColdFusion Markup Language) tags such as <CFQUERY>, <CFIF> and <CFLOOP>. ColdFusion was introduced by Allaire in 1996 and is currently on version 4.0

Hello World Program in ColdFusion
Now that we've talked a bit about the language, let's try creating a simple "Hello World" program in ColdFusion. When a user requests a ColdFusion page (usually a file with extension .CFM) from your Webserver, the ColdFusion Server runs the page and then outputs a standard HTML page for your Webserver to return to the user's browser. In this case, where there are just HTML tags and no CFML tags in the page, no processing is done, and the HTML just passes through unchanged. So if you wanted to write a "Hello World" program in ColdFusion it would simply consist of HTML:

Listing 1: Hello World.cfm


<HTML>
<BODY>
Hello World
</BODY>
</HTML>
If there are CFML tags then ColdFusion will process them, calculating any variables, if statements, and loops and return the dynamically generated HTML. If you are familiar with C, then you might compare ColdFusion to a super C preprocessor for HTML!

Note: The fact that web pages stand alone, separated from the server, is one of the more confusing points of writing web applications. It is sometime described as stateless. This means that each page doesn't automatically retain any memory or state from preceding pages unless your code explicitly passes the information around. Compare this situation to a traditional program in Basic or C, where you can easily pass global variables or parameters around different screens in your program.

Let's add some ColdFusion code to our "Hello World" example, so that if will ask for the user's name and display Hello [your name] instead. In standard HTML web pages, you must get input such as the user's name on a new page, separate from the page where you process the input. This is because once a page is displayed on your browser the communication with the webserver has ended. For the server to do further calculations requires a second page request. (It is possible to run code on the browser, but this requires the use of JavaScript or other client-side add-ons to HTML that we won't get into here.)

So we add a new page called "GetName.cfm" to get the user's name, and we change the display page to "HelloWorld2.cfm" as shown in Listings 2 and 3 below:


<HTML>
<BODY>
<FORM NAME="GetName" ACTION="HelloWorld2.cfm" METHOD="post">
<INPUT TYPE="TEXT" NAME="FirstName">
<INPUT TYPE="SUBMIT"	VALUE="OK">
</FORM>
</BODY>
</HTML>

Listing 2: GetName.cfm


<HTML>
<BODY>
<CFOUTPUT>
Hello, #FirstName#
</CFOUTPUT>
</BODY>
</HTML>

Listing 3: HelloWorld2.cfm

The first page, "GetName.cfm," is straight HTML for an input screen. The second page, "HelloWorld2.cfm," contains two ColdFusion constructs. The first construct, the <CFOUTPUT> tag, turns on ColdFusion variable output (with the matching </CFOUTPUT> tag turning it off). The second construct, the pound symbol (#), delimits the variable FirstName, that is passed as a form variable from the "GetName.cfm" page. (For a discussion of when and where to use pounds signs in variables, see Michael Dinowitz's article, "3P2," in this issue.) If you type the name Michael into the first page, you will see "Hello, Michael" on the screen and the following HTML will have been generated:


<HTML>
<BODY>
Hello Michael
</BODY>
</HTML>

Let's do one final thing with this example, and have it say Good morning, afternoon or evening depending on the time of date of the server. We will use the ColdFusion functions Now() and Hour(), which return the current date/time and the hour (between 0 and 23) of a given date.


<HTML>
<BODY>
<CFOUTPUT>
	<CFIF Hour(Now())GT 18>
		Good Evening,
	<CFELSE Hour(Now())GT 12>
		Good Afternoon,
	<CFELSE>
		Good Morning,
	</CFIF>
	#FirstName#
</CFOUTPUT>
</BODY>
</HTML>

Listing 4: HelloWorld3.cfm

In Listing 4 above, we have also used the <CFIF>, <CFELSE> and </CFIF> tags, which allow the page to display different results depending on whatever conditions you might prefer (in this case, the hour of the day). Notice that because we are using HTML, the carriage returns in the text don't matter, and the greeting "Good Morning, Michael" will appear on one line. If you wanted the text on two lines, you would use the standard line break HTML tag (<BR>) before the variable #FirstName#.

ColdFusion contains over a hundred functions for Arrays, Date and Time, Decisions, Display and Formatting, Dynamic Evaluation, List Processing, Structures, International, Mathematics, Strings, System values and Query manipulation. There are about 70 tags for Database Manipulation, Data Output, Variable Manipulation, Flow-Control, Internet Protocols, File Management, Web Application Framework, ColdFusion Forms, External System Tags. Additionally you can write your own new tags in either ColdFusion or C. For a listing of these tags, see the Allaire site http://www.allaire.com. or request a ColdFusion tag chart from http://www.teratech.com/product/productdetail.cfm?product=TAG1 (free to CF Advisor readers).

How ColdFusion Works
A ColdFusion application is very simply a collection of pages, similar to a static Web site. But unlike the pages in a static Web site, the pages in a ColdFusion application include the server-side ColdFusion Markup Language (CFML) in addition to HTML. CFML gives you the ability to control the behavior of your applications, integrate a wide range of server technologies, and dynamically generate the content that is returned to the Web browser.

When a browser requests a page in a ColdFusion application, it is automatically pre-processed by the ColdFusion Application Server. Based on the CFML in the page, the Application Server executes the application logic, interacts with other server technologies, and then dynamically generates an HTML page, which is returned to the browser.

The diagram below shows what happens when a Web browser requests a page in a ColdFusion application.

 
  1. When a user requests a page in a ColdFusion application by submitting a form or clicking a hyperlink, the user's Web browser sends an HTTP request to the Web server via the Internet or Intranet.

  2. The Web server passes the data submitted by the client and the requested page to the ColdFusion Application Server either through a server API or CGI. ColdFusion pages are automatically compiled and cached in memory so processing in ColdFusion is very fast and scaleable even under high loads.

  3. ColdFusion reads the data from the client and processes the CFML used in the page. Based on the CFML, the ColdFusion Application Server executes the application logic and interacts with a wide range of server technologies including database, email and files.

  4. ColdFusion dynamically generates an HTML page and returns it to the Web server.

  5. The Web server then passes the page back to the user's Web browser.

What are People Building with ColdFusion?
Web developers are using ColdFusion to build a wide range of Internet, Intranet, and Extranet applications including:

Electronic Commerce

  • Online stores and catalogs
    • NetGrocer (www.netgrocer.com) is the first nationwide on-line grocery store. Driven entirely by Cold Fusion, the service allows shoppers to create a shopping list, send food to others and set up recurring orders to save time and money.

    • Wickes Lumber (www.wickesnet.com) Wickes, one of the nation's largest building materials suppliers, used ColdFusion and ColdFusion components to develop WickesNet, a system that allows builders to do everything from monitoring accounts and paying bills to checking inventory at the nearest Wickes Lumber Store.
  • Supply chain management
  • Business to business electronic commerce
  • One to one marketing and Web site personalization
Collaborative Computing
  • Online discussion groups
  • Project management
What else can I do with ColdFusion?
If all you could do with ColdFusion was assign variables and use the <CFIF> tag to conditionally output web pages, it would be pretty lame. But you can do many other things including:
  • Retrieve data from any ODBC database including Access and SQL server

  • Run any SQL query including INSERT, UPDATE and DELETE queries

  • Send customized email with CFMAIL

  • Loop over database queries, list or do For-Next loops

  • Handle errors and relocate to different pages

  • Automatically read pages from other websites using CFHTTP
To Learn More
If you are interesting in learning more about ColdFusion, you can read the presentations that took place at the free ColdFusion User Conference on Saturday 6/26/99 in Bethesda, Maryland. Just visit http://www.teratech.com/cfconf/ for copies of all the presentations, and read the CF Advisor report for a summary of what went on.

You can download a free 30-day evaluation version of ColdFusion from Allaire or request a free eval CD-ROM from the Allaire website http://www.allaire.com/

Allaire Corporation
One Alewife Center
Cambridge, MA 02140

Tel: 617.761.2000 voice
Fax: 617.761.2001 fax
Toll Free: 888.939.2545
Email: sales@allaire.com

Other ColdFusion Resources
Allaire also maintains an extensive knowledge base and tech support forums on their website.

TeraTech maintains a ColdFusion code cuttings page called ColdCuts at http://www.teratech.com/ColdCuts/. This page also has links to about a dozen ColdFusion white papers in the CF Info Center.

There are many user groups around the country. For a listing of user groups, see the user group section on CF Advisor, or the Allaire site.

Published Sep. 16, 2003— Reads 5,512
Copyright © 2003 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
About Michael Smith
Michael Smith is president of TeraTech (www.teratech.com/), an
11-year-old Rockville, Maryland-based consulting company that
specializes in ColdFusion, database, and Visual Basic development.

Add Your Feedback

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON Featured Whitepapers

ADS BY GOOGLE

Breaking Java News
Siliconware Precision Industries Reports a 3.8% Quarter-over-Quarter Decline in Revenues Resulting in Earnings per Share of NT$ 0.38 or Earnings per ADS of US$ 0.06 for Fourth Quarter 2011
Norwest Venture Partners Invests $15M in Manthan Systems
Norwest Venture Partners Invests $15M in Manthan Systems
Cotendo Receives Prestigious Frost & Sullivan New Product Innovation Award
U.S. Census Bureau Daily Feature for February 15
U.S. Census Bureau Black History Month Feature for February 15
IEEE Announces No-Cost Public Access to Select IEEE C95TM Standards for Exposure to Electromagnetic Fields
AMD Radeon(TM) Breaks GHz Barrier
China Telecom Partners With iPass to Deliver Wi-Fi Roaming Exchange Services

ADVERTISE   |   MAGAZINE SUBSCRIPTIONS   |   FREE BREAKING-NEWSLETTERS!   |   SYS-CON.TV   |   BLOG-N-PLAY!   |   WEBCAST   |   EDUCATION   |   RESEARCH

.NET Developer's Journal - .NETDJ   |   ColdFusion Developer's Journal - CFDJ   |   Eclipse Developer's Journal - EDJ   |   Enterprise Open Source Magazine - EOS
Open Web Developer's Journal - OPENWEB   |   iPhone Developer's Journal - iPHONE   |   Virtualization - Virtualization   |   Java Developer's Journal - JDJ   |   Linux.SYS-CON.com
PowerBuilder Developer's Journal - PBDJ   |   SEO / SEM Journal - SJ   |   SOAWorld Magazine - SOAWM   |   IT Solutions Guide - ITSG   |   Symbian Developer's Journal - SDJ
WebLogic Developer's Journal - WLDJ   |   WebSphere Journal - WJ   |   Wireless Business & Technology - WBT   |   XML-Journal - XMLJ   |   Internet Video - iTV
Flex Developer's Journal - Flex   |   AJAXWorld Magazine - AWM   |   Silverlight Developer's Journal - SLDJ   |   PHP.SYS-CON.com   |   Web 2.0 Journal - WEB2
Apache   |   CMS   |   CRM   |   HP   |   Oracle Journal   |   Perl   |   Python   |   Red Hat   |   Ruby on Rails   |   SAP   |   SaaS

SYS-CON MEDIA:   ABOUT US   |   CONTACT US   |   COMPANY NEWS   |   CAREERS   |   SITE MAP
SYS-CON EVENTS:   |  AJAXWorld Conference & Expo  |  iPhone Developer Summit  |  Cloud Computing Conference & Expo  |  SOA World Conference & Expo  |  Virtualization Conference & Expo
INTERNATIONAL SITES:   India  |  U.K.  |  Canada  |  Germany  |  France  |  Australia  |  Italy  |  Spain  |  Netherlands  |  Brazil  |  Belgium
 Terms of Use & Our Privacy Statement     About Newsfeeds / Video Feeds
Copyright ©1994-2008 SYS-CON Publications, Inc. All Rights Reserved. All marks are trademarks of SYS-CON Media.
Reproduction in whole or in part in any form or medium without express written permission of SYS-CON Publications, Inc. is prohibited.
 
close this window