DBMS
 

 

Allaire Cold Fusion 2.0 Professional

By John M. Telford
DBMS, February 1997 Cold Fusion is a Web application development tool for people who want to use the Web to create dynamic-page applications and interactive Web sites on corporate Intranets and the Internet.

Unlike the cold fusion hoax that rocked the physics world to its core a few years ago, this Cold Fusion is real, and better than ever. It does not use smoke and mirrors like the physics experiment allegedly did. Cold Fusion 2.0 Professional is a server-side Web application development tool. It uses the Cold Fusion Markup Language (CFML) to create dynamic Web pages on a Web server. Cold Fusion includes an application framework with client state management and Crystal Report integration. This product is an excellent example of Web client/server, server-side processing.

Cold Fusion 2.0 Professional is the latest product release from Allaire Corp. (For a review of Cold Fusion 1.5, see DBMS, July 1996, page 33.) New features include Web server API integration, an application framework with client-state management, and dynamic report generation using Crystal Reports 5.0. CFML now supports compound Boolean expressions, string concatenation, looping, and more than 130 date, time, list, and string functions. There is also extensive date, time, and number formatting. Java Graphlets are now included with Cold Fusion. In addition, the Cold Fusion API (CFAPI) lets C and C++ developers extend Cold Fusion with custom tags. Cold Fusion 2.0 requires Windows NT 3.51 or later or Windows 95. Cold Fusion works best with a Web server API. It supports Microsoft Personal Internet Information Server, Microsoft Internet Information Server, Netscape Enterprise and FastTrack Servers, and O'Reilly WebSite 1.1e or Pro. It works with any of the Common Gateway Interface (CGI)-compatible Web servers but will deliver only a subset of functionality compared to what is provided by a Web server API. You will not be able to use document type mapping, native Web server security, and relative mappings with CGI. In addition, performance is decreased, and the examples shipped with the product will not work.

The trends in Web client/server application development seem to be revisiting some of the paths legacy client/server traveled on its way to failure. Somehow, developers are not listening to the ghost of client/server past. Instead, they fatten up clients by downloading them with mass quantities of ActiveX and Java junk food. An appropriate amount of ActiveX and Java is vital for thriving clients, but so many Web sites throughout the intergalactic Internet are gorging our Web clients with junk when we visit their home pages. I don't know about you, but I do not like waiting while a bloated ActiveX component or Java applet clogs my 28.8 Kbps Internet lifeline. I like it even less when the BLOB forced down my Web client's throat chews up my CPU cycles to boot. I hope the ghost of client/server future gets developers thinking, "It's the server, stupid." Cold Fusion helps keep Web clients thin. Most business logic, display logic, data logic, and data formatting can live on the Web server. Some navigation logic and input field validation needs to be on the Web client, but almost everything else can be processed on the Web server side, including accessing databases. There is a groundswell of interest in downloading Java Database Connectivity (JDBC) applets and accessing databases directly from Web clients. Of course, this means that business logic, display logic, data logic, and data formatting must also be downloaded to fatten up the client.

At the heart of Cold Fusion is an application server running as a multi-threaded Windows NT systems service. When a Web client clicks on a URL containing a Cold Fusion template file, such as www.server.com/hotlink.cfm, the Web browser includes the template file name in the HTTP data stream sent to the Web server. The Web server passes control on to the Cold Fusion systems service. The hotlink.cfm file is really a text file containing a template for generating a dynamic Web page. It contains CFML tags, HTML tags, and possibly client-side features such as JavaScript and VBScript tags. The Cold Fusion systems service only processes CFML tags; it leaves the other tags alone. You can use CFML tags to generate JavaScript and VBScript tags. After processing CFML tags, the Cold Fusion systems service returns the resulting HTML Web page to the Web server. The Web server then sends the HTML Web page on to the Web browser.

CFML sort of reminds me of the AWK programming language. I had a passion for AWK during the Unix golden years, until I met Perl. Perl has grown so that it now holds chunks of the Internet together. In the good old days -- a Web decade ago or so -- Perl was the choice scripting language to use with CGI. I doubt the World Wide Web would have taken off with such a blast without CGI and Perl. I still have a love affair with Perl, and I use it where appropriate, but I think Cold Fusion 2.0 Professional CFML is a more appropriate way to generate server-side dynamic Web pages, most of the time, and for most Web content developers. Developers will find CFML syntax easier to learn because it is less cryptic than Perl, but I wish Cold Fusion did pattern-matching and regular expression processing like Perl. You do not need to be intimate with the CGI standard or HTTP cookie standard to get at the information sent in the HTTP stream by the Web client. It is readily available to CFML developers in the form of Cold Fusion variables. The main reason to use Cold Fusion 2.0 Professional CFML instead of CGI and Perl is probably its integration with ODBC databases and Crystal Reports.

The CFML integration with ODBC databases and Crystal Reports 5.0 is superb. You can use CFML to dynamically customize SQL statements using data from form submissions, URL query strings, and HTTP environment variables, as well as results returned from other queries. You can also execute multiple SQL queries and send SQL queries to multiple databases for each Web client request. Runtime customization of Crystal Reports includes dynamically setting the selection formula, sort order, target data source, and any custom formula within a report.

A Cold Fusion template file is used to select and output data from a database. It contains both CFML and HTML tags. The database query is done with the SQL contained in a <CFQUERY> tag. The output is done with a <CFOUTPUT> tag. CFML also includes a pair of tags, <CFTABLE> and <CFCOL>, that work together to present query results in a tabular format. The following CFML template query example returns records that satisfy the WHERE clause.

<!-- QueryExample.cfm -->
<CFQUERY NAME="QueryExample"
DATASOURCE="QueryExampleData" MAXROWS=5>
SELECT * FROM Clients
WHERE ClientName = '#ClientName#'
</CFQUERY>

<HTML>
<HEAD><TITLE>Query
Example</TITLE></HEAD>

<CFOUTPUT QUERY="QueryExample">
<HR>
#ClientName# <BR>
#Address1# <BR>
#Address2# <BR>
Phone ##: #Phone# <BR>
Fax ##: #Fax# <BR>
#Description#
</CFOUTPUT>

</HTML>

The CFML variable #ClientName# is set by the Web client user in the following Web form:

<HTML>
<HEAD><TITLE>Query Example
Form</TITLE></HEAD>
<FORM ACTION="QueryExample.cfm" METHOD=POST>

<INPUT TYPE=TEXT NAME="ClientName" size=32 maxlength=80>
<INPUT TYPE=SUBMIT VALUE="Submit">

</FORM>
</HTML>

Cold Fusion 2.0 supports the integration of Crystal Reports into Web applications through the use of the <CFREPORT> tag. In the following example, the <CFREPORT REPORT> tag calls the Crystal Reports engine and embeds the EMPLOYEES.RPT report in the Web page. The selection formula within the <CFREPORT> enclosure uses the value of Departments to restrict the records that will be displayed by the report.

<!-- GenerateReport.cfm -->
<HTML>
<HEAD><TITLE>Crystal Reports Example</TITLE></HEAD>

<CFREPORT REPORT="#EMPLOYEES.RPT">
{Employees.Department} IN "#FORM.Departments#"
</CFREPORT>

</HTML>

The value of Departments is selected by the Web client user in the following Web form:

<HTML>
<HEAD><TITLE>Crystal Reports Example Form</TITLE></HEAD>
<FORM ACTION="GenerateReport.cfm" METHOD=POST>

<SELECT NAME="Departments" MULTIPLE SIZE=4>
<OPTION VALUE="Sales" SELECTED>Sales
<OPTION VALUE="Accounting" SELECTED>Accounting
<OPTION VALUE="Engineering" SELECTED>Engineering
<OPTION VALUE="Administration" SELECTED>Administration
</SELECT>
<INPUT TYPE=SUBMIT VALUE="Generate Report">

</FORM>
</HTML>
One key to developing successful Web server dynamic HTML pages is keeping track of Web client-specific state information. It is important to update this information as Web clients move through your Web application HTML pages. There are several standard ways to do it: You can tack parameters onto a URL; you can use hidden form fields; you can use HTTP cookies. Cold Fusion supports all of these methods. It also supports another way, which is called client state management. The CFML application developer defines any number of parameters to associate with a Web client. Cold Fusion generates a unique token that identifies the Web application and the Web client and uses this token to create an entry in the system registry for each parameter defined by the CFML application developer. It also stores the unique token in an HTTP cookie managed by the Web browser. Each time a Web browser user clicks on a URL for the Web application, the Web browser sends the contents of the cookie back to the Web server in the HTTP data stream. CFML uses the token stored in the returned cookie when the CFML application developer wants to read, store, and delete client parameters stored in the system registry. Mucking around in the system registry is a dangerous thing to do, especially if you do not know what you are doing. Cold Fusion knows what it is doing: using the system registry as a database. This is a reasonable thing to do, because the system registry is a database. Many other programs use it as such.

Examples of Cold Fusion are easy to find. One example, the Allaire Web site, is a showcase for a Cold Fusion Web application using dynamic Web pages generated by the Web server. While you are there, be sure to click your way to and run all of the Cold Fusion 2.0 examples. A simple Hello World example demonstrates the basic concept of dynamic Web page generation. A National Park search example shows a basic database search for national parks. A Corporate Crystal Report example displays a sample dynamically generated Crystal Report. A Virtual Reality Markup Language (VRML) example demonstrates the use of Cold Fusion to dynamically generate VRML content from a database query. One example that illustrates some of the value the product brings to the marketplace is the Java Sales Reporter. (See Figure 1.) It shows off Cold Fusion Java graphlets that come with the product. It also uses the Cold Fusion Database Component Framework (DCF) for Java. DCF enables Cold Fusion developers to integrate database-driven Java components into Web applications without low-level Java programming.

Allaire is encouraging the Java developer community to create applets for Cold Fusion developers. The Cold Fusion product already ships with bar chart, multi-bar chart, area chart, pie chart, and Java applets. More are sure to follow. These sorts of Java applets are examples of appropriate goodies to feed Web clients. They will not make them fat, and they provide the functionality that Web clients need. My advice to Web content developers is, if you can possibly do it on the Web server, just do it there.

You can use Java applets and JavaScripts with Netscape Enterprise Server to generate dynamic Web pages on the Web server. You can use ActiveX, Java applets, JavaScript, and VBScript, with Microsoft Internet Information Server 3, to generate dynamic Web pages on the Web server. You can incorporate ActiveX, Java applets, JavaScript, and VBScript into Cold Fusion 2.0 dynamic Web pages, but you cannot use them to generate dynamic Web pages on the Web server using Cold Fusion. I would like to see Allaire support using ActiveX, Java applets, JavaScript, and VBScript in Cold Fusion. You then could use these technologies and CFML to generate dynamic Web pages on the Web server. You could create dynamic Web pages utilizing technology available on the Windows NT Server platform and have a choice of which Web server to use.

Cold Fusion 2.0 is an excellent example of Web client/server, server-side processing: Use it to generate dynamic Web pages on the Web server. Access databases using an integrated ODBC interfaces. Populate dynamic Web pages with data that has been messaged using date, time, list, string, math, and formatting functions. Create Crystal Reports for Web clients. Help keep Web clients thin. Use Cold Fusion to keep business logic, display logic, data logic, and data formatting on the Web server. Relegate CGI and Perl Web application development to the Web legacy hall of fame. Get your copy today and discover what a hot product Cold Fusion 2.0 is.


Figure 1.


--The Java Sales Reporter uses Cold Fusion Java graphlets and the cold Fusion Database Component Framework for Java.


John Telford is a distributed systems architect, software practitioner, and project manager. He formed InfoMax Consulting more than five years ago and has been working in the computer business for more than 30 years. John can be reached at jmt@infomax.com or through his Web page at home.sprynet.com/sprynet/jmt/infomax.htm.
Subscribe to DBMS and Internet Systems -- It's free for qualified readers in the United States
February 1997 Table of Contents | Other Contents | Article Index | Search | Site Index | Home

DBMS and Internet Systems (http://www.dbmsmag.com)
Copyright © 1997 Miller Freeman, Inc. ALL RIGHTS RESERVED
Redistribution without permission is prohibited.
Please send questions or comments to dbms@mfi.com
Updated Wednesday, January 22, 1997.