Overview of the Components of ColdFusion MX


The growing popularity of ColdFusion is because it's easy to use, easy to learn, and lets you create large database applications. To understand the capabilities of ColdFusion, you need to understand how it works, how Web servers work, and how the two work together.

Before understanding ColdFusion development, here's an overview of the various existing Internet technologies and how ColdFusion fits into them.

The Internet

The Internet is the world's largest network. It contains high-speed backbones that large telecommunications companies own and operate. There are local access points run by phone companies, online services, and local Internet Service Providers (ISPs).

The common language on the Internet is Internet Protocol (IP). This is the protocol used to communicate across the Internet, so every computer connected to the Internet must run a copy of IP.

The unique identifiers are IP addresses. Every computer or host that's connected to the Internet has a unique IP address. Each address is made up of four sets of numbers separated by periods, such as 101.111.150.10. Some hosts have fixed or static IP addresses, and others have dynamically assigned addresses. Regardless of how an IP address is obtained, no two hosts connected to the Internet can use the same IP address at any given time.

Internet Applications

The Internet has been dubbed "the Information Superhighway." It's simply a massive communications network and, by itself, offers little to most users.

The most popular application on the Internet is the World Wide Web. It's the Web that single-handedly transformed the Internet into a household word. As mentioned, all Internet applications use IP to communicate across the Internet. The information transmitted by these applications is broken into packets, or small blocks of data, which are sent to a destination IP address. The application on the receiving side then processes the received information.

IP addresses are the only way to uniquely specify a host. When you want to communicate with a host, such as a Web server, you need to specify its IP address. You rarely specify IP addresses directly; you specify the destination address. The Domain Name Service (DNS) does the mapping of the host name to the IP address.

The World Wide Web is built upon a protocol called Hypertext Transfer Protocol (HTTP). HTTP is designed to be a protocol that's well suited for distributed multimedia information systems and hypertext links between sites.

Web Pages

On the World Wide Web, information is stored in Web pages. A Web page can contain any of the following:

  • Static text

  • Input boxes (Textbox, Combo Box, List Box, Checkbox, or Radio Button)

  • Headers

  • Menus

  • Tables

  • Forms

  • Graphics

  • Multimedia

Web pages are plain-text files created using Hypertext Markup Language (HTML). HTML is implemented as a series of tags or instructions. Browsers use these tags to display the information for viewing.

On a Web server, pages are stored in different directories. When requesting a Web page, a user may provide the full path, the directory, and the filename to specify a particular document. However, the user does not need to remember the directories and path names. The user generally specifies the home page URL, and the navigation links help the user retrieve the desired resource.

Web Servers and Web Browsers

The original development of the World Wide Web was performed using different variants of UNIX. Now, Web servers hosted on Windows NT are becoming more and more popular. This is because UNIX is still more expensive to run than Windows NT, and it's also more difficult for an average user to use. Windows NT has proved to be an efficient, reliable, and cost-effective platform for hosting Web servers.

A Web server is a program that serves up Web pages on request. When a user at a specific IP address requests a specific file, the Web server tries to retrieve that file and return it to the user. The requested file might be the HTML source code for a Web page, or a GIF image. It's the Web browser that determines what should be requested, not the Web server. The server processes the request. The Web server returns the requested page as it is, regardless of what it contains. If there are HTML syntax errors in the file, those errors are returned along with the rest of the page.

Connections to Web servers are made on an as-needed basis. If you request a Web server for a Web page, an IP connection is made over the Internet between your host and the host running the Web server. The requested Web page is sent over that connection, and as soon as the page is received, the connection is broken.

Web browsers are client programs used to access Web sites and pages. A Web browser processes Web pages it receives, parses the HTML code, and displays the page to the user. The browser attempts to display graphics, tables, forms, formatted text, or whatever else the page contains. The most popular Web browsers are Netscape Navigator and Microsoft Internet Explorer.

URLs

Every Web page has an address called a Uniform Resource Locator (URL). URLs aren't just used to identify World Wide Web pages or objects. The files on an FTP server also have URLs that identify them, for example.

A typical URL is in the following format, consisting of up to five parts:

 protocol://host:port/path/filename?querystring 

These parts are as follows:

  • protocol. This is the protocol used to retrieve the object. For example, HTTP is used for resources on the World Wide Web.

  • host. This is the Web server from which the resource is to be retrieved. It can be the DNS name or the IP address of the server.

  • port. This is the port on the host machine on which the Web server software is running. If omitted, the default port of the specified protocol is used. For Web servers, the default port is 80.

    Note

    This port is not a physical port on the server machine. Instead, it is a memory area that is allocated for client/server socket communication.

  • path/filename. This is the file to be retrieved or the script to be executed.

  • querystring. This is an optional script parameter. The application developer can use his own query string as per his requirements.

The links in Web pages are references to other URLs. When a user clicks a link, the browser processes the URL that the link references.

CGI

Web servers can do more than just serve static pages. They can execute scripts as well. When a Web server receives a URL request that references a script, the server executes it and returns the script's output.

For example, suppose you have a Web site that reports stock prices. Creating Web pages that list all the stocks by exchange, along with their current values, would be extremely difficult. As fast as you could update the page and save it, it would be out of date already because information changes every second when the stock exchange is in session. Instead, you need to write a script that takes a stock symbol as a parameter and returns the current value. When a user requests a stock, the Web server will execute the script referred to in the URL, pass the stock symbol as a parameter, connect the script to your designated system to obtain the stock prices, and generate HTML output containing the quoted price.

To make it easier to create scripts that work with multiple Web servers, a standard script interface called the Common Gateway Interface (CGI) is used. CGI isn't a program or a script. Instead, it's a mechanism that's used to connect your script to a Web server.

When a CGI script executes, the following sequence of events occurs:

  1. The Web server creates a new session in which to execute the script.

  2. A set of standard environment variables is set, containing information that the script might need. This includes the IP address of the remote host, the URL that was specified, and the server and browser version information.

  3. The script is then executed within this session, using any parameters that are passed to it.

  4. The Web server captures any output generated by the script.

  5. Once the script has finished running, the session is terminated and the captured output is sent to the requester's browser.

In the past, most CGI programs were actually script files and were often written in scripting languages such as PERL. Today, though, scripts can also be executable programs. You can write scripts in C and Visual Basic. Some Web servers even enable you to execute batch files as scripts. As long as your program can execute without any user intervention, it can be a script.

CGI scripts are a powerful way to extend the capabilities of your Web server. However, CGI has certain shortcomings:

  • Creating sessions and executing scripts is time-consuming, especially when multiple requests are running concurrently.

  • CGI applications, by their very nature, must be loaded and unloaded each time they're used. There's no way to load a CGI script and keep it ready for future use.

  • CGI applications are entirely distinct from the Web server itself. CGI cannot be used to change the behavior of a Web server; it can only be used for URL redirection.

Server APIs

Programmers use Application Programming Interfaces (APIs) to write applications that can interact with other applications. A server API is a published interface that allows software developers to write programs that become part of the Web server itself. Usually, these are Windows Dynamic Load Libraries (DLLs) that are loaded into the memory and stay resident at all times.

Because server APIs are closely tied to the Web servers themselves, each API is server-specific.

ColdFusion Components

In its early form, ColdFusion was a CGI script. Every time a user made a ColdFusion request, the Web server executed the entire ColdFusion program. ColdFusion would then process the user's request, perform whatever actions were necessary, and return the HTML output to the user. Using Perl for server-side programming is an example of CGI. Whenever a .pl file is requested, Perl.exe with the requested file as a parameter is executed and output is directed to the outbound HTTP stream.

As the set of features in ColdFusion increased, so did the response time of the application. Because CGI programs are loaded and unloaded when needed, there's no way to maintain variables, settings, database connections, and file handles between each executed session. As a result, performance was a serious problem. The latest version of ColdFusion has a scaleable and elegant new design with the following capabilities:

  • The ColdFusion engine is a Windows NT service. This means ColdFusion can remain running at all times, even when no one is logged in to the server.

  • The Web servers themselves cannot communicate with a ColdFusion NT service. Therefore, there are server modules for the three different ColdFusion server APIs.

  • For Web servers that don't support server APIs, a CGI script called CF.EXE was created. This CGI script ensures that any Web server that supports the CGI specification can be used with ColdFusion. The CGI script interface to ColdFusion is slower than the server API interface. Therefore, it should be used only when the server modules cannot be used.

The ColdFusion NT service is the program that actually parses and processes any supplied instructions. Instructions are passed to ColdFusion using templates, which are similar to HTML files with one major difference. Unlike HTML files, ColdFusion templates can contain special tags that instruct ColdFusion to perform specific operations.

Whereas Web servers typically pass back the contents of a Web page without processing the file contents, when ColdFusion receives a request, it parses the template to search for special ColdFusion tags or ColdFusion variables and functions. Any HTML or plain text is left alone and is sent to the Web server as-is. Any ColdFusion instruction is processed, and if there are results, they're also sent to the Web server. The Web server can then send the entire output back to the requester's browser.

The core components of ColdFusion MX are

  • ColdFusion Markup Language (CFML) and the scripting environment

  • ColdFusion Application Server

  • ColdFusion Administrator

CFML and the Scripting Environment

ColdFusion Studio is an Integrated Development Environment (IDE) for ColdFusion. It offers a complete graphical environment for the development of applications.

The ColdFusion scripting environment provides an efficient development model for Internet applications. At the heart of the ColdFusion scripting environment is CFML, a tag-based programming language. With CFML, you can enhance the standard HTML files with database commands, conditional operators, high-level formatting functions, and other elements to rapidly produce Web applications. However, CFML is not limited to enhancing HTML. For example, you can create Macromedia Flash MX applications consisting entirely of Flash elements and CFML. Similarly, you can use CFML to create Web services for use by other applications. CFML is covered in detail in Chapter 2, "Overview of CFML."

You can extend CFML by creating custom tags or User-Defined Functions (UDFs), or by integrating COM, C++, and Java components. You can also create ColdFusion components that encapsulate the related functions and properties and provide a consistent interface for accessing them. For custom tags, refer to Appendix A, "Creating ColdFusion MX Custom Tags."

Macromedia Dreamweaver MX helps you develop ColdFusion applications. It includes many features that simplify and enhance ColdFusion development, including tools for debugging CFML. You can also use an HTML editor or a text editor, such as Notepad, to write ColdFusion applications.

Note

Other text editors are not recommended.

Another feature of the ColdFusion scripting environment is server-side ActionScript. This is the JavaScript-based language used to write application logic in Macromedia Flash MX. ColdFusion MX enables Flash developers to use their familiar scripting environment to connect to ColdFusion resources, and to deliver the results to client-side applications using the integrated Macromedia Flash Remote service. Using server-side ActionScript, Flash programmers can create ColdFusion services, such as SQL queries, to be used by Flash clients.

ColdFusion Application Server

The ColdFusion application services are a set of built-in services that extend the capabilities of the ColdFusion scripting environment. The application server handles the process of taking files containing CFML and HTML and converting them into complete Web pages for delivery to the user's browser.

The application services include the following:

  • Tracking the client state, load balancing, and clustering. These features relate to scalability.

  • Open integration, including support for the XML standard and built-in support for database servers such as Oracle and Sybase.

  • Security features, including a comprehensive authentication system.

ColdFusion MX Administrator

The ColdFusion MX Administrator application configures and manages the ColdFusion application server. It's a secure Web-based application that you can access using a Web browser from any computer with an Internet connection.

You can manage the following options with ColdFusion Administrator:

  • ColdFusion data sources

  • Debugging and logging output

  • Server settings

  • Application security

  • Site-management tasks

  • Performance tuning

Linking to External Applications

One of the most powerful features of ColdFusion is its capability to connect to data that's been created and maintained in other applications. You can use ColdFusion to retrieve or update the data in many applications, such as Oracle, SQL Server, and ASCII-delimited files.

ColdFusion accesses these applications via Open Database Connectivity (ODBC), is a standard interface that applications can use to interact with a diverse set of external data stores.




Macromedia ColdFusion MX. Professional Projects
ColdFusion MX Professional Projects
ISBN: 1592000126
EAN: 2147483647
Year: 2002
Pages: 200

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net