Local time: Friday, 05-Dec-2008 12:10:42 EST
Last update: at /special/conference/apwww95 , Friday, 21-May-2004 09:47:30 EST

Implementation of a Back-End Database for HTML Forms

Paul Gunther

IBM Australia
Coonara Avenue, West Pennant Hills, NSW 2125, Australia

paulgun@austin.ibm.com


Abstract
This paper details an implementation of a back-end database for HTML (hypertext markup language) [htm95] input forms. This would be applicable to any World Wide Web (WWW) application requiring search and retrieval facilities from a database. Database sizes tested are 6MB. The implementation uses the Object Data Manager (ODM) [odm95] from AIX [aix95] and Korn Shell scripts.

This method has several advantages:

  • Simple database maintenance [ben92]
  • Simple manipulation and maintenance of scripts
  • No additional software required outside of the AIX base operating system
  • Simple query specification
  • Good performance

Note: this is a less functional alternative to a commercially available database and HTML forms package. [cic95][dbt95]

Keywords
HTML database forms odm object data manager backend cgi-bin cics db2 aix

Introduction

Selecting a database input form and output report application is a major decision that affects:

Choosing a proprietary solution can lock you into an architecture that exacerbates the global access of your data in an open environment.

The World Wide Web (WWW) [www95][red95] initiative provides a platform independent and architecture independent client [cli95] that accesses an information server.

This server can act as a gateway to a database. Enterprise and legacy databases can be connected to a web client. A simple database implementation is described here.

Forms

The hypertext markup language (HTML) defines input forms that allow data to be sent to a server for processing. Typical input fields include:

Other input types include:


The following example demonstrates these input types:

This is the HTML source excerpt for this input form:


<form method="post" action="http:/cgi-bin/action.ksh">
<p>
What sort of assignment method to use?
<select name="method">
<option>Round Robin 
<option>Random
<option>Territory
<option>Customer
<option>Product
</select>
<p>
What input data do you want to feed to the simulation ?
<select name="data">
<option>95/02/06
<option>95/02/07
<option>95/02/08
<option>95/02/09
<option>95/02/10
<option>big_list
</select>
<p>
<input type=submit value="Start Simulation">
<input type=reset value="Reset default values">
<hr>
<h3>Advanced Parameters</h3>
<p>Keep backlog ?
<input name=accumulate type=checkbox>
<p>Absolute pathname of custom MAP file:<input name=map size=40>
</form>

The HTML source defines the variable names for the form input fields. These field values are passed to the information server for processing.

The following sample korn shell script takes the form input for processing. In the example the variable name method is made available to the shell script as the environment variable FORM_method.


#!/bin/ksh
# File : action.ksh
# Process form input

eval `cgiparse -form` # convert form input into environment variables

cat << EOF
Content-Type: text/html

<html>
<title>
Queueing Simulation Result
</title>
<h1>Simulation</h1>
<p>The result of the test data through the simulator
are as follows:
EOF

echo $FORM_method

Object Data Manager (ODM)

AIX provides a built-in, lightweight database as part of the Base Operating System. This database is called the Object Data Manager (ODM) [inf95]. The ODM allows applications to create a database table or 'object class'. Here is a sample object class definition:

class CPU {
        char machine_type[5];
        char machine_model[4];
        char serial[8];
        char comment[20];
};

The shell environment variable ODMDIR specifies the location of class instances. The file containing the previously defined class definition is used to create the object class.

For example:

ODMDIR=/database/cpu
odmcreate myclass

Population of the database is achieved via the command:

odmadd

Better performance is found using the ODM application programming interface (API) [inf95]. A C excerpt to populate a database from a flat ASCII input file follows:

#include "myclass.h"

main()
{
        struct myclass s;

	/* initialize file */

        odm_initialize();

        while ( /* more input */ ) {

		/* initialize structure members */

                odm_add_obj(myclass_CLASS, &s);

		/* read next line from file */
        } /* while */

        odm_terminate();
} /* main */

Class queries can be performed using a syntax similar to Structured Query Language (SQL). For Example, to select from the class 'CPU' any matching entries where the serial field is a sliding match to the value *1234*, run the following query:

odmget -q "serial like *1234*" CPU

ODM Form Integration

Connecting the HTML form input to the database is achieved by using the form field values as arguments to the ODM query.

Any database back-end will require a processing application to:

  1. Interpret the form input
  2. Perform legal value checking
  3. Format the input fields for database processing
  4. Execute the required database queries
  5. Format the report query result

Consider the following HTML form excerpt:

<h1>Query</h1>
<p>Enter search criteria:
<form method="post" action=/cgi-bin/report.ksh>
<p><input name=serial size=20> Serial
</form>

This might appear similar to the following when rendered by a web client:


The form processing application report.ksh is located in the directory as specified in the web server configuration for common gateway interface (CGI) executables.

Consider the korn shell source to report.ksh:


#!/bin/ksh

eval `cgiparse -form`

cat << EOF
Content-Type: text/html

<html>
<title>
Report
</title>
<h1>Report</h1>

<pre>
EOF

ODMDIR=/database/cpu
odmget -q "serial like $FORM_serial" CPU | grep comment

This dynamically creates HTML output comprising header information [htm95] followed by the result of the database search. The output in this case is simply filtered by grep'ing for the comment field. Other formatting is achieved programmatically as needed.


The dynamically created HTML may appear like this as viewed from a web client:


Limitations

This sample implementation has the following limitations:


Legacy System Migration

Existing legacy applications using the 3270 data stream do not require re-architecting [leg94] in order to migrate to a WWW environment.

IBM's CICS Internet Gateway provides an efficient 3270 data stream to HTML translator, obviating the requirement to develop a new backend transactional database system.

For example, here is a CICS Application screen.

This shows the 3270 data stream translated into HTML.



For more information see http://www.hursley.ibm.com/cics/saints/main.html


World Wide Access to DB2

IBM's DB2 World Wide Web Connection provides an HTML forms-based input model to create dynamic SQL database queries and return the result as a nicely formatted HTML report.


The architecture of these components is:

For further information see http://www.torolab.ibm.com/data/db2/db2wannc.html


Conclusions:

Use of a World Wide Web browser client to access an information server running any database is the ideal mechanism to provide global, client-independent data access. The client provides the HTML formatting independent of database query output or database type.

Development of a back-end database for HTML forms requires an application to provide all the input, database query, and output functions. Several products previously described connect the HTML input form to the back-end database in an automated and easy to use manner.


Acknowledgements:

The author would like to thank Andrew Wilson and Debby Nakamura.


References:
[htm95]
T.Berners-Lee, D.Connolly: Hypertext Markup Language - 2.0, URL http://www.w3.org/hypertext/WWW/MarkUp/html-spec/html-spec_toc.html
[ben92]
Ben Gibbs: Demystifying the Object Data Manager, Volume 2, Number 2, /AIXtra April 1992 URL http://sq.ibm.com/aixtra/
[ben92]
Ben Gibbs: Demystifying the Object Data Manager - Part 2, Volume 3, Number 3, /AIXtra July 1992 URL http://sq.ibm.com/aixtra/
[dbt95]
IBM Corporation: DB2 World Wide Web Connection, URL http://testcase.boulder.ibm.com/db2wwelc.html
[cic95]
IBM Corporation: IBM CICS Internet Enabling - CICS Internet Gateway, URL http://www.hursley.ibm.com/cics/saints/main.html
[aix95]
IBM Corporation: AIX Operating System, URL http://www.austin.ibm.com/software/OS/VersionInfo.html
[glo95]
IBM System User International: CICS on AIX more like the mainframe, URL http://www.globalnews.com/ibmsu/iss12/cics.htm
[inf95]
IBM Corporation: , AIX Version 4.1 General Programming Concepts: Writing and Debugging Programs - Base Information Hypertext Library, Chapter: Object Data Manager (ODM)
[leg94]
IBM Corporation: Legacy Applications: Do They Really Need a Fountain of Youth?, URL http://pscc.dfw.ibm.com/sq/issues/vol22/legacy.htm
[red95]
IBM Corporation: Using the Information Super Highway,GG24-2499, URL http://www-i.almaden.ibm.com/redbooks/abstracts/gg242499.00.html
[www95]
w3.org, The World Wide Web, http://www.w3.org/hypertext/WWW/
[cli95]
Anita Hamilton and Greg Pastrick, Web Browser Shoot Out, http://www.cnet.com/Central/Features/Browser/
* DB2 and CICS are registered trademarks of the IBM Corporation
[Return to Table of Contents]
COPYRIGHT © 1995 by AUUG95 and APWWW95 Charles Sturt University. ALL RIGHTS RESERVED. ISBN 1 875781 43 9