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.
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:
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.
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.
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.
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.
ColdFusion dynamically generates an HTML page and returns it to the Web server.
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
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.
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.
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: