The World Wide Web was designed as an information-sharing medium using static hypertext markup language (HTML) documents. The Common Gateway Interface (CGI) extended HTML to allow the dynamic construction of Web pages by server-resident programs. This article discusses how application developers are building solutions for the Internet today using CGI programming standards. Also discussed is IBM’s newly announced Net.Data product, which simplifies the task of writing CGI programs that access DB2 legacy databases and host-centric legacy applications.
The CGI Standard
The CGI standard allows Web developers to create applications that interact with Web end users. This standard describes how data from a fill-in HTML form is passed back to the HTTP Web server, where an invoked program processes the data. CGI programs follow a formal process to send response data back to Web users. Figure 1 shows the flow of data from a Web browser to an HTTP server to a CGI program and back. Because CGI programs format and send tailored HTML documents (because each user supplies new and unique information on the form), they are building what is referred to as dynamic Web pages.
The CGI program flow can be broken into three steps.
1. The user completes a form that may contain text boxes, check boxes, buttons, or other response devices.
2. When the user clicks on the submit button, data flows to the HTTP Web server (in our case, an AS/400).
3. The HTTP server places the form data into a standard area, either as environment variables or as standard input, and then invokes the CGI program. The CGI
program parses and processes the forms data and then builds a dynamic HTML document that is returned through the HTTP server to the user.
Because the CGI standard was developed on UNIX-based systems, the languages and methods used to implement CGI programs reflect their UNIX heritage. Prior to AS/400 Web server products such as IBM’s Internet Connection for AS/400, I/NET’s WebServer/400, and Advanced Business Link’s BusinessLink/Web, CGI programs were almost always written in languages such as C, Perl, and Tcl—languages that most AS/400 developers do not have expertise in. With the AS/400 products, CGI programs can be developed in RPG, COBOL, CL, and C.
IBM and other companies are taking the developments a step further. They are delivering prepackaged CGI programs called gateways that can be used without in- depth knowledge of CGI programming and standards. Examples of gateway programs include IBM’s 5250 HTML Gateway, I/NET’s Webulator, and OpenConnect’s OC://WebConnect—all prepackaged CGI programs that convert IBM 5250 green-screen data streams to HTML and vice versa, thus allowing Web browsers to run IBM 5250- based applications across the Internet. IBM also markets gateways for Information Management System (IMS), Customer Information Control System (CICS), and the MQ Series, delivering Web access to applications using these products.
This article focuses on Net.Data, an IBM gateway for interacting with data stored in DB2 databases (whether running on OS/400, OS/390, AIX, OS/2, Solaris, or HP/UX). Net.Data is a renamed and enhanced version of what used to be called DB2WWW. Net.Data is provided by IBM at no extra charge with all its Internet Connection products. On the AS/400, Net.Data is included in the no-charge program product 5763-TC1 (5617-TC1 for RISC boxes).
What exactly does Net.Data do, and how does one start using it? Let me give you a simple example that shows what a Net.Data application would look like to a Web user using Netscape Navigator. First, the Web user would see a form like the one shown in Figure 2. This Web application allows the user to request status information for a particular insurance claim. The user keys the claim number into the form field, clicks on the Start Query button, and gets the status of the claim in real time. Figure 3 shows the response back to the user. All of this is accomplished with the IBM gateway, Net.Data.
The screen in Figure 3 is a unique, dynamically created Web page that is tailored to the user, based on the claim number entered on the fill-in form. Net.Data allows the developer to create dynamic pages using data in their application databases by using a high-level macro language, thus shielding developers from the complexities of CGI programming.
How the Sample Program Was Written
Figure 4 shows the Net.Data macro used to create and execute the sample application. Net.Data macros have four key parts: an input section denoted by the %HTML_INPUT macro; a define variable section denoted by one or more %DEFINE macros; a report section denoted by the %HTML_REPORT macro; and the SQL section denoted by a %SQL macro. I will give you a high-level view of how the process flows from input to response. Figure 5 shows the flow of events in a hypothetical macro.
First, a Web user navigates to an HTML link in the following form: http://as400.here.com/QSYS.LIB/CGI.
Net.Data
LIB/DB2WWW.PGM/www/XMP/input where the underlined section is the macro that the DB2WWW.PGM uses to process the request. Note that although the DB2WWW product has been renamed Net.Data, the CGI program, DB2WWW, has not been renamed. The DB2WWW.PGM is the CGI that Net.Data provides. Notice the last part of the URL, specifically the input parameter. This signals the DB2WWW.PGM to read the XMP macro and process the HTML INPUT section. The HTML INPUT section’s duty is to create an HTML document that the Web user fills in to initiate the query. When the user fills in the forms and clicks the Submit Query button, the DB2WWW.PGM CGI is again invoked with a URL much like the one above but with a minor difference: the final parameter is report instead of input. Net.Data then uses the HTML REPORT section to perform SQL operations upon the DB2/400 database and to format a dynamic Web page in response.
Figure 6 shows you the %HTML_INPUT section. Our hypothetical user clicked on a hyperlink:http://pid400f/db2www/CLAIMQJOIN.MBR/input The Net.Data program was invoked and used the macro file CLAIMQJOIN.MBR, parsing it to find the %HTML_INPUT section that you see in Figure 6. Note that Net.Data macros are blocked, meaning that everything between the macro’s %HTML_INPUT{ and the matching %} is included in the macro. The input section builds a fill-in form using standard , , and the important tag has an ACTION attribute in the form:
Figure 6: %HTML_INPUT
LATEST COMMENTS
MC Press Online