TrAC - Internet Column


To cite this article please refer to the printed edition of TrAC: Trends Anal. Chem., 16 (1997) (in preparation)

Overview of interactive programming methods for the World Wide Web

Brian M. Tissue

Department of Chemistry, Virginia Polytechnic Institute and State University, Blacksburg, VA 24061-0212, USA

[email protected]

Introduction

This article provides an overview of common programming methods for creating interactive material for the World Wide Web (Web) [1,2]. Incorporating interactive elements on a Web page is useful for a variety of tasks in education and business, including delivery of interactive educational or training materials, and data entry and database access using on-line forms. My intent is to provide a basic description of interactive methods to help users understand the source of interactivity on Web pages, and to provide a starting point for developers who must choose an appropriate programming tool for some task.

It is possible to create "interactive" material without programming by using basic hypertext markup language (HTML) elements. For example, it is possible to produce multiple-choice tutorials by simply using hyperlinks for each answer choice. When a choice is selected, the hyperlink retrieves a new HTML page that indicates if the choice was correct or incorrect, and can also provide an explanation or a return link to try the exercise again. An extension of this hyperlink method is to create a graphical multiple-choice exercise using a clickable image map (see Appendix). Although these approaches are simple, they are limited to "hard-wired" choices. To place more sophisticated interactive material on a Web page requires HTML form elements (see Appendix), and a programming method to evaluate user input. This article concentrates on interactive elements that can return a calculational or relational response to a user's input, or access a database to submit or retrieve information.

The largest distinction between the different interactive methods discussed below is that some are client-side, in which all processing is done on the client computer; and others are server-side, in which all processing is done on the Web server. Client-side methods include JavaScript [3], Java™ [4], ActiveX™ [5], and plug-ins. Server-side methods include server-side scripting languages, and programs called through the Common Gateway Interface (CGI). Client-side methods are most appropriate for presentations, and practice or training exercises. Client-side methods do not transfer data over the internet for the data-processing step, and therefore can be much faster compared to server-side methods. This consideration can be very important for interactive material that might require many repetitive actions. Server-side methods are most appropriate when information must be submitted or retrieved from a database on a server. They also have the advantage that they are "browser-neutral," i.e., they provide programming capabilities that are independent of the flavor or version of a user's browser. Some example applications include input forms to access existing databases of information, educational or training modules that track usage or save grades to the server, and dynamically generated Web pages. Client-side and server-side methods can be combined on the same Web page. A common example is to use a client-side JavaScript to check the format of data entry before it is submitted to a server-side program for evaluation.

Client-side methods

Client-side JavaScript and VBScript

JavaScript [3] and VBScript™ (Visual Basic™ Scripting Edition) [6,7] are scripting languages that Web browsers can interpret. They are similar to other interpreted languages in that they are fairly easy to use, and they allow authors to incorporate programming features into Web pages without a full-featured compiled language. For the client-side implementations of these languages, the script code is contained in the HTML document between <SCRIPT>...</SCRIPT> tags, usually in the header section. When a Web browser loads an HTML file, the browser parses any script statements that are present, and displays any script write statements before displaying the HTML code in the body of the document. Once a page is loaded, a script can recognize and respond to a number of user events such as mouse position, form input, and button clicks. Form elements such as radio buttons and text boxes allow users to enter data by selecting choices or typing text. This information can be evaluated by a script function, which then returns a response. Scripts can also communicate with other elements on a web page, such as Java applets and ActiveX controls, and control frame or page navigation.

The disadvantage of using client-side scripts alone is that there is no direct access to the server's hard disk to save user input, or to retrieve information from a database. For security reasons, neither of these languages will read or write to a user's local hard disk. Netscape Navigator™ 3.0 supports JavaScript but not VBScript, and Internet Explorer™ 3.0 supports both VBScript and JavaScript. The interpretation of JavaScript code is not completely equivalent in Internet Explorer and Netscape Navigator, and older browser versions might not print script-generated Web pages.

Java applets and ActiveX controls

Java was developed by Sun Microsystems, Inc. to create a simple object-oriented and platform-independent programming language to distribute application programs (called applets) over the Web [4]. Creating a Java applet involves writing a Java program, compiling it into a file of Java bytecodes, and including a reference to the applet using <APPLET>...</APPLET> tags in an HTML file. When a Java-enabled browser encounters the applet tags, the browser downloads the specified Java applet, interprets the Java object code, and runs it in a window on the browser screen. Applets are stand-alone programs that can accomplish a broad range of functions such as animation, calculations, graphing, etc., and could find wide utility in the creation of interactive presentations, training, and educational material.

Microsoft is developing a similar technology called ActiveX [5]. ActiveX is a set of protocols, whereas Java is a programming language; but an ActiveX control functions analogous to a Java applet. ActiveX controls are written in Visual C++™ (or other languages) and are incorporated into Web pages using <OBJECT>...</OBJECT> tags. They can also be incorporated into other stand-alone applications that are developed with Microsoft programming languages. Currently Internet Explorer 3.0 supports Java and ActiveX, but Netscape Navigator 3.0 supports only Java. ActiveX controls can also be viewed in Netscape Navigator 3.0 using the ActiveX plug-in [8].

Plug-ins and helper applications

Plug-ins are software add-ons that allow a browser to display file types that are not inherently supported by the browser [9,10]. Non-supported file types can also be displayed by configuring a browser to launch a helper application for a specific file type. In either case, these file types are most useful for presentations, educational or training material, and sharing files between users. One of the popular methods for animations and presentations is the Shockwave™ plug-in, which displays Macromedia Director™, Authorware™, and Freehand™ files [11]. There are a number of other software tools for visualizing and manipulating objects and data of specific interest to chemists. The Chime™ Plug-in can display and manipulate molecular images in *.pdb and *.xyz file formats [12]. Figure 1 shows an example of a PDB (protein data bank) file displayed in Netscape Navigator with Chime. Stand-alone RasMol programs have the same or greater functionality as Chime, and can be configured as helper applications [13,14]. The current de facto standard for sharing formatted files, such as word-processor documents, is the Portable Document Format (PDF). PDF files can be viewed and printed with the free Adobe Acrobat plug-in and Reader helper application [15]. Many software vendors also provide free viewers for their application files [16]. One notable educational example is the free stand-alone Mathbrowser™ for downloading and viewing Mathcad™ worksheets [17].

[Fig. 1] Fig. 1. Screen capture of a PDB file displayed in Netscape Navigator with the Chime plug-in. Molecule file courtesy of K. Brewer.

Server-side methods

Server-side scripts

Netscape and Microsoft are developing server-side versions of JavaScript and VBScript, respectively. The main advantages of server-side scripting are the ability to access databases and to dynamically generate Web pages that can be tailored specifically for a user. Netscape calls their current server-side version of JavaScript LiveWire™ [18], and it will be integrated into their Enterprise Server™ software. Microsoft's technology for their Internet Information Server™ is called Active Server Pages (ASP) ™ [19], which supports both VBScript and Jscript (Microsoft's implementation of JavaScript). Server-side scripting is mostly transparent to the user (ASP generated files have an *.asp extension rather than *.html, ref. [5] is an example), but some older browser versions might not print script-generated pages.

Common Gateway Interface (CGI)

The Common Gateway Interface (CGI) is a standard protocol to pass information from a browser program running on a client computer to an application program running on a Web server [20]. When a browser requests a *.cgi file, the server executes the script or program that is contained in that file. The CGI interface also passes any data that was submitted from the client to the program. The program evaluates the user input and returns a response. The CGI can interface to any language that can be executed on a Web server, such as C/C++, FORTRAN, TCL (Tool Command Language), PERL (commonly called Perl, although it is an acronym for Practical Extraction and Report Language), VisualBasic, HyperCard, and AppleScript. Non-compiled languages, such as PERL, are usually preferred due to their ease of modification, maintenance, and debugging (PERL is also free) [21]. CGI programs are executed on the Web server using the resources of the server computer. Processor-intensive applications or the ability to serve many clients simultaneously can create a heavy load for a Web server, requiring a powerful computer. The advantages of the CGI method are the abilities to use sophisticated programming languages and to access the server's hard disk to use existing databases or log user responses.

Related methods

Security dialog boxes often pop up asking a user to enter a username and password. These prompts are part of the Web server software and restrict file access to registered users.

Dynamic HTML (DHTML) will (probably) allow scripts to control all objects on a Web page based on user information or action [22]. It will primarily be a tool for page layout and animation, but will also provide interactive capabilities for presentations and tutorials.

Push technology provides a means for a server to automatically send information to a user; either to an e-mail box, a personal Web page, or to a separate client program. The information that is sent is determined by a user profile, and these services are useful to monitor new product information or the scientific literature [23].

Conferencing software allows various types of interpersonal and group communication. Some capabilities include text-based chatting, slide presentation, whiteboard display, audio, and video [24,25,26].

Virtual Reality Modeling Language (VRML) allows visualization and manipulation of 3-D objects in a window on a Web page [27]. The user can change the position from which the object is viewed, including zooming in and out. VRML objects can include hyperlinks making it possible to use them as interactive 3-D presentations or exercises. Apple has a similar panning and linking capability for QuickTime movies called QuickTime VR [28]. VRML files have a *.wrl extension and QuickTime VR files have the same *.mov extension as regular QuickTime movies. VRML appears to be most useful for visualizing 3-D-rendered objects, and QuickTime VR is primarily used for panoramic scenes created from video.

Summary

The programming methods discussed above are useful to enhance Web page functionality with interactive elements that can range from simple presentations or form entry to sophisticated and complex applications. Client-side methods such as JavaScript, Java, and plug-ins are suitable for presentations, educational and training material, and Web page navigation. Client-side scripts can also verify user input before submitting it to a server. Server-side scripting languages and the CGI interface allow utilization of sophisticated programming languages, creation of dynamically generated Web pages, and access to databases on the server hard disk. Netscape, Microsoft, and third-party developers are creating development tools for the various scripting and programming languages [1,29,30]. These tools will simplify the creation of interactive elements on Web pages. However, the continuing evolution of the specifications of HTML, Web browsers, and Web programming languages will no doubt require occasional maintenance of the programming code.

Acknowledgments

This work was supported by an NSF Career Grant (CHE-9502460) and a Research Corporation Cottrell Scholars Award. I am grateful to Ron Earp for his assistance with the JavaScript and PERL programming endeavors of the Chemistry Hypermedia Project [31].

Appendix

Image maps

Clickable image maps are images on a Web page that contain active areas within the image [32]. Clicking on an active area calls a specified URL, which can be a hyperlink or a call to a JavaScript function. Image maps can be client-side or server-side. The client-side map information is contained in the same HTML file as the Web page that is being displayed, and the server-side map information is in a map file on the Web server. Client-side maps operate faster than server-side maps because they do not reconnect to the Web server for each click on the image map. Client-side maps are also easier to develop because the files can be tested and edited on a local disk before transferring the HTML file to a Web server. Server-side maps have the advantage that the map information is not available to the user, so they can be used as interactive graphical exercises in on-line testing material. Clickable image maps can be created easily using one of the free or inexpensive image map programs that are available on the Web [1,33,34].

HTML form elements

HTML form elements provide the Web-page interface for users to supply information. The same HTML form elements serve to submit information to either a client-side script, or to a server-side program of a Web server. The HTML code for the form elements are contained between the <FORM> and </FORM> tags. Some common examples include text boxes; select boxes; and radio, submit, and reset buttons [1]. The following listing gives the HTML code for these examples, and Figure 2 shows how these elements look on the browser screen.

<FORM NAME="form1" ACTION="http://www.edu/test.cgi" METHOD="post">
<H3>Text Input:</H3>
<INPUT TYPE="text" NAME="txtbox1" VALUE="Type some text here." SIZE="30">
<H3>Radio Buttons:</H3>
<INPUT TYPE="radio" NAME="test1" VALUE="1">Try clicking this button,
<INPUT TYPE="radio" NAME="test1" VALUE="2">and this button,
<INPUT TYPE="radio" NAME="test1" VALUE="3">and this button, all at once.
<H3>A Select Box:</H3>
<SELECT NAME="numbers">
<OPTION VALUE="1">ONE
<OPTION VALUE="2">TWO
<OPTION VALUE="3">THREE
<OPTION VALUE="4">FOUR
</SELECT>
<H3>Buttons:</H3>
<INPUT TYPE="button" VALUE="Click Here" OnClick="test2()">
<BR>
This button calls a JavaScript function that pops up an alert box.
<BR><BR>
<INPUT TYPE="reset" VALUE="Reset">
<BR>
This <EM>Reset</EM> button returns all of the form elements to default values.
</FORM>

[Fig. 2] Fig. 2. Screen capture of some form elements as they appear on a Web page.

References

Note: All URLs listed in this article were verified 5/27/97.

[1] A good starting point to find programming and Web tools is: Yahoo! Inc., Yahoo! - Computers and Internet:Internet:World Wide Web.

[2] There are lots of books on the programming methods discussed in this article. Since these programming tools and specifications change so rapidly, my best suggestion is to check an on-line book seller such as http://www.amazon.com/.

[3] Netscape Communications Corp., JavaScript Authoring Guide.

[4] Sun Microsystems, Inc., JavaSoft Home Page.

[5] Microsoft Corp., ActiveX Overviews.

[6] Microsoft Corp., VBScript Web Page.

[7] Microsoft Corp., VBScript Documentation.

[8] NCompass Labs Inc., NCompass ScriptActive.

[9] Netscape Communications Corp., Inline Plug-Ins.

[10] Netscape Communications Corp., Plug-in Guide (primarily for developers).

[11] Macromedia, Shockwave Center.

[12] MDL Information Systems, Inc., MDL Chemscape Chime.

[13] E. Martz, RasMol home page.

[14] M. Molinaro, UCB Enhanced RasMol.

[15] Adobe Systems Incorporated, Adobe Acrobat Free Reader.

[16] Microsoft Corp., Microsoft Free Downloads.

[17] MathSoft, Inc., Math Mathbrowser Home Page.

[18] Netscape Communications Corp., Netscape Livewire Data Sheet.

[19] Microsoft Corp., Active Server.

[20] NCSA HTTPd Development Team, The Common Gateway Interface.

[21] The Perl Language Home Page.

[22] L. Wood, Document Object Model (DOM).

[23] See for example: CARL Corporation, Reveal Home Page.

[24] Netscape Communications Corp., Netscape Navigator 3.0 | CoolTalk.

[25] Microsoft, Corp., NetMeeting.

[26] PlaceWare, Inc., PlaceWare News.

[27] Silicon Graphics, Inc., vrml.sgi.com.

[28] Apple Computer, Inc., Apple QuickTime VR Home.

[29] Netscape Communications Corp., Netscape Visual Javascript.

[30] Microsoft Corp., Microsoft Visual InterDev Start Page.

[31] R. L. Earp and B. M. Tissue, CHP Interactive Exercise Prototypes.

[32] Rogers, Imagemap Help Page -- Instruction.

[33] Mediatech Inc., LiveImage (Win32 version only).

[34] Boutell.Com, Inc, Mapedit (Windows 3.1, Win32, and UNIX versions only).

Brian M. Tissue received a B.A. in chemistry from the Johns Hopkins University in 1983 and a Ph.D. in analytical chemistry from the University of Wisconsin-Madison in 1988. He held postdoctoral positions at the University of Georgia and Los Alamos National Laboratory before beginning his current position of Assistant Professor in the Department of Chemistry at Virginia Polytechnic Institute and State University in 1993. His research interests include laser spectroscopy of lanthanide-doped nanocrystalline materials, time-of-flight mass spectrometry, and applications of computer and network technology in chemical education.

©1997 Elsevier Science B.V.