Research and Advances
Artificial Intelligence and Machine Learning

Integrating Web Sites and Databases

Posted
  1. Introduction
  2. Web Page Programming Options
  3. Client-Side Processing
  4. Conclusion
  5. References
  6. Authors
  7. Figures



From a performance standpoint, because compiled programs execute faster than scripts, busy Web servers should use compiled server-side programs.


Popular languages for creating compiled server programs are Java, Visual Basic, and C++, but almost any language that can create executable programs can be used, providing it supports commands used by one of the protocols that establish guidelines for communication between Web servers and servicing programs. The first such protocol (introduced in 1993) for use with HTML forms was the Common Gateway Interface (CGI); many servicing programs on Web sites today still use CGI programs. However, a disadvantage of using CGI-based servicing programs is that each form submitted to a Web server starts its own copy of the servicing program on the Web server.

A busy Web server is likely to run out of memory when it services many forms simultaneously; thus, as interactive Web sites have gained popularity, Web server vendors have developed new technologies to process form inputs without starting a new copy of the servicing program for each browser input. Examples of these technologies for communicating with Web servers include Java Servlets [2] and Microsoft’s ASP.NET [1]; they allow a single copy of the servicing program to service multiple users without starting multiple instances of the program.

ASP.NET has introduced many new capabilities to server-side Web programming, including a new category of elements called server controls that generate as many as 200 HTML tags and one or more JavaScript [5] functions from a single server control tag. Server controls support the processing of user events, such as clicking a mouse or entering text at either the client browser or the Web server. Server controls also encourage the separation of programming code into different files and/or areas from the HTML tags and text of a Web page, thus allowing HTML designers and programmers to work together more effectively.

ASP.NET allows the developer to choose between a server-side hybrid processing model and a compiled model; this dual approach is why ASP.NET is included in both categories in Figure 1. The compiled model creates Web application projects, or collections of files providing the functionality for each application. Visual Studio.NET’s development environment, called VB.NET, is almost identical to the development environment it provides for Web application projects. Included are reliable integrated debugging, graphic design tools, and project management. Since none of these functions is available when the hybrid model is used, ASP.NET is likely to be used as compiled rather than as hybrid technology.

Programs created through ASP.NET are not backward compatible with ASP scripts created through the original ASP server-side scripting technology [6]; upgrading older ASP scripts to ASP.NET requires substantial revision. ASP and ASP.NET programs can, however, run on the same Web server, as ASP.NET programs are distinguished with .aspx file extensions.

 Server-side scripts

Web-based applications can also use server-side scripts to create dynamic Web pages that are able to retrieve and display database data and modify data records. The processing architecture is the same as the processing architecture used for compiled server programs, except the Web server processing is performed through an interpreted text script rather than a compiled program.

Scripts using the CGI communication protocol are usually written using the Practical Extraction and Report Language (PERL) scripting language, which contains features derived from Unix, C, and BASIC. The current version of PERL, Version 5, handles binary and text file processing on a variety of operating system and Web server platforms. The language itself is terse, with many operations and commands specified with one- or two-character commands; special characters (such as $, #, %, and /) are used frequently to indicate data types and operations.

Figure 2 shows an example of a PERL script designed to interact with a HTML form. The HTML form allows a user to enter a name in a text box referenced as username and select an option button in a radio button group referenced as color. When the user clicks Submit, the PERL script executes and displays the name the user entered, along with text displaying the label of the selected option button.

PERL includes functions for manipulating text strings and processing files with descriptive names, making it easier to understand and work with the code. Although it is possible to write well-documented, maintainable PERL scripts, the language encourages cryptic shortcuts. PERL scripts can therefore be difficult to understand and maintain. Moreover, they use the CGI protocol, so each time a script is requested a new copy of it is automatically invoked.

Macromedia’s Cold Fusion solves the CGI problem of starting a new copy of the program each time it is requested by allowing a single running script to serve multiple requests. It also provides a different approach from PERL for creating server-side scripts. Instead of embedding HTML outputs in coded print statements, as PERL does, a Cold Fusion script looks like an ordinary HTML page with code embedded in the HTML; this approach allows HTML page designers to create Web pages and add code as needed.

A number of newer scripting technologies developed since 1995 have taken the Cold Fusion approach to embedding code within HTML by allowing a single running script to service multiple requests. Figure 3 includes examples of such scripts using Cold Fusion, Microsoft’s ASP, and the Apache Software Foundation’s PHP; all do the same thing as the PERL script in Figure 2—access the username entered and the color selected on the HTML form and write them to a new Web page. Although the syntax varies, the approach is the same—embed code statements within ordinary HTML.

If needed, a developer can have a single Web server process a variety of scripts written with any or all of these technologies. The Web server knows which script interpreter to invoke by taking note of the requested script’s file extension. Cold Fusion files have .cfm file extensions in their name, PERL scripts have .pl file extensions, and ASP scripts have .asp extensions.

 Server-side hybrid processing

Compiled server-side programs offer two main advantages: They are first compiled and stored in a machine-readable format; they do not need to be translated into a machine-readable format each time they execute, so they usually run faster than scripts. Second, compiled programs are usually created in integrated development environments that provide debugging utilities, thus making it easy to locate and correct errors. The advantage of using scripts is that their modification requires only a text editor rather than installation of an associated development environment. Hybrid server-side programming strives to combine the advantages of compiled server-side programs and server-side scripts; a server-side script is created but not compiled. The first time a user accesses a Web page calling the script, the script is compiled into machine-readable format and stored as an executable file. With this approach, the developer works with ordinary text files and does not need to install an integrated programming development environment to modify the script. Performance is improved because the program does not need to be translated into machine language each time it runs.

Soon after Microsoft introduced ASP technology in 1997, Sun Microsystems introduced Java Server Page (JSP) technology. Unlike ASP scripts, JSP source code is automatically compiled into machine-readable format the first time a user accesses it. The Web server saves the compiled JSP program, using it (rather than the source code) the next time anyone else tries to access this particular JSP. This scheme reduces both the processing performed and the time the user has to wait to view a response from the Web server. If a programmer modifies the JSP source code, the Web server notes that the source code file has been modified since the compiled version was created, compiling and saving the compiled program the next time a user accesses the page; Figure 4 shows a JSP page equivalent of a script that is functionally equivalent to the scripts in Figure 3. The examples in Figure 3 are complete, but the JSP example in Figure 4 would require writing an additional program (a JavaBean) defining getProperty and other required methods.

 Choosing server-side processing

From a performance standpoint, because compiled programs execute faster than scripts, busy Web servers should use compiled server-side programs. Why use scripts at all? Scripts are preferable when a large program is not required for processing HTML form inputs; creating a short script is faster than creating a short compiled program. For example, a programmer can readily modify a script using a text editor. To modify a compiled program, programmers must have the associated programming environment installed on their workstations, as well as the program’s original source code. After the program source code is modified, it must be recompiled. This makes modifying a short compiled program more complicated and time-consuming than modifying a short script.

Programmers using a CGI program should be aware that CGI server-side programs can be written in any language supporting the CGI protocol, and a CGI program can be used with any Web server and operating system supporting the language in which the CGI program is written; C, C++, and PERL are popular choices. Visual Basic is a popular choice for Web servers running in the Microsoft Windows environment. However, there are no VB compilers for other operating systems.

CGI’s main drawback is its inefficient use of Web server resources. A number of public and proprietary Web servers and Web server add-on products have been developed to enable a single CGI program loaded into memory to service multiple submissions of the same form. One such product, called Persistent CGI is included in Zope, an open source Web server available from Zope Corp. in Windows and Unix/Linux versions. Another solution to the CGI performance problem is FastCGI, an open source extension for existing Web servers; links to FastCGI add-ons for Microsoft, Netscape, and Apache Web servers are available at www.fastcgi.com.


If being on the leading edge is of no concern to the e-commerce organization developing a site, its developers should consider using ASP.NET.


ASP.NET has impressive new capabilities, though it involves a much steeper learning curve than many other competing products, including Microsoft’s own ASP; ASP.NET will, however, be a major player in the coming years as developers learn more about it.






Join the Discussion (0)

Become a Member or Sign In to Post a Comment

The Latest from CACM

Shape the Future of Computing

ACM encourages its members to take a direct hand in shaping the future of the association. There are more ways than ever to get involved.

Get Involved

Communications of the ACM (CACM) is now a fully Open Access publication.

By opening CACM to the world, we hope to increase engagement among the broader computer science community and encourage non-members to discover the rich resources ACM has to offer.

Learn More