Processing the User's Request

The second function of most CGI programs is to process the CGI input data or user's request. Usually, this is a calculation, database lookup, or file read, although CGI programs can invoke modules of an existing application to perform a function and return data. This is the part of CGI programming that is most familiar to COBOL developers: the application processing component.

It is important to note that since CGI programs are executed on the Web server machine by the Web server itself, they are not allowed to perform any user interface operations directly. If a CGI program attempts any operation that waits for a user response, it may cause the Web server to "hang."

Therefore, when writing CGI programs, you should be especially careful not to include code that waits for user input (using the ACCEPT verb).

There are some cases when the runtime displays a message box even before loading the COBOL program. There are other cases when the runtime shuts down due to an error that is not handled by the COBOL program. In these cases the runtime displays a message box containing the text of the message and waits for the user to press the OK button. This can cause a problem when the runtime is executed by a Web server.

To solve this problem, when you are configuring the Web server to execute the runtime, be sure to use the "-f" command line option or to configure your environment with the A_CGI environment variable. Both of these methods cause the runtime to suppress warning messages that are normally displayed in a message box. When the runtime shuts down due to an error that is not handled by the COBOL program, it constructs an HTML, XML, or WML page containing the shutdown message and sends it to the standard output stream before terminating. for more information, see Configuring the Web Server.