CGI Programming

CGI programs on this server can access Mainframe data stored in very fast and efficient VSAM datasets, DB2 databases, flat files, and other sources. This can be combined with the use of Java applets and scripting to provide all the necessary glamour and function of a world class web site. We cannot think of anything you can't do with this WEB server.

The DragonFly Server CGI 1.40 implementation is not based on standard Web Server CGI protocols. The reasons for this follow. If this is an issue with your installation, a standard version of CGI interfaces can be supplied.

.. The DragonFly CGI interface uses memory pointers. Memory pointers are an incredibly fast way to move data between programs. STDIN, STDOUT and non compiled scripts do not make the grade for Enterprise data manipulation because they are inefficient and slow. To maintain a sense of familiarity, the variables in your program may be referred to as STDIN and STDOUT.

In future releases if there is sufficient demand, Java and Rexx scripts may be incorporated into the server CGI interface. In the meantime, no CGI functional capability is being sacrificed. Java and rexx are of course already available client side.

The CGI program will be passed a pointer on which a structure is based.

The structure contains the following variables.

VARIABLE Description
STDIN LENGTH4 byte binary length field
STDIN currently 32696 bytes
STDOUT LENGTH4 byte binary length field
STDOUT currently 32696 bytes
RC 4 byte binary return code for error tracking
MIME for describing the data type sent to the browser

(there are special notes for COBOL which does not support pointers)

The CGI programs can access files in the usual manner. They must build their own HTML and may optionally build the http header. The MIME variable in addition to standard MIME types can contain the keyword ASIS to allow the programmer to completely control the Web Server output. The RC is set to 1 upon calling the CGI program. If the CGI program is successful it should change the RC to 0 and if unsuccessful to whatever error code it would like the server to display on the browser in plain text. Output from the CGI programs is sent via the DragonFly server to the client making the request.

CGI program names must be of the format CGIPGM1, CGIPGM2...CGIPGM4 or for COBOL, CGIPGMA,CGIPGMB...CGIPGME. are recognized and properly executed by the Dragonfly Server.

Returning Data

CGI programs can return content in many different document types (i.e. text, images, audio). They can also return references to other documents. To tell the server what kind of document you are sending back, CGI requires you to place a short header on your output. This header is text, consisting of lines separated by either ASCII linefeeds or carriage returns (or both) followed by a single blank line. The output body then follows in whatever native format.

If you set the MIME variable to "ASIS" then the DragonFly Server will send all output exactly as the CGIPGM has written it to the client. Otherwise, the Dragofly Server will send a default header back (text/html file type) with any data returned from the script. Important: If you do not choose to write the entire HTTP header, you should not provide any special headers, as they will appear as part of the body after Dragonfly Server processing.

If you begin your script with any of the following:

the DragonFly Server will append the appropriate HTTP response status (200 or 302) followed by the headers and content of your script exactly as received.

For example, to send back HTML to the client, your output should read:

         Content-type: text/html
         <TITLE>output of HTML from CGI PGM</TITLE>
         <H1>Sample output</H1>
         etc, etc, etc.

In the above example, the response prefix is: HTTP/1.0 200 OK
To reference a file on another HTTP server, you would output something like this:

         Content-type: text/html
         <TITLE> moved</TITLE>
         <H1>Content Moved!</H1>

In the above example, the response prefixed is: HTTP/1.0 302 MOVED Important: The Location: directive comes prior to the Content-type: directive.


By default, the DragonFly Server tests the return status of CGI programs and displays to the client the RC output from the CGI program if the exit status is not 0. Important: If your CGI application returns a non-zero error code, and does not print an error message to SYSPRINT, you will see only the following:

  CGI Failure..RC=10

CGI Buffers

Form strings can be a maximum of 32,696 bytes in both directions.

© 1998-2002 Tyson Systems. All rights reserved. Terms of Use.