“HTML” on page 95 documents or Web pages are either static or dynamic. Static Web pages exist as static HTML files on the Web server. Dynamic Web pages exist only as temporary documents to satisfy a specific individual request. Dynamic Web pages enable the user to interact with the Web server; for example, to order
merchandise over the Web.
Although your IBM HTTP Server serves both static and dynamic Web pages, dynamic Web pages do not reside on the server. You can create dynamic Web pages by using “CGI” on page 95 application programs. When the server receives a request from the user’s browser, it passes this request to the CGI application program. The CGI program processes the request and passes the response to the server. The server then passes the response back to the browser. That response could be the results of a search, text that is extracted from a database, or a form for the user to complete. The form of the response depends on the design of the Web site.
The IBM HTTP Server for AS/400 Web Programming Guide provides information about writing CGI programs for AS/400. It includes environment variables, application program interface (API), Persistent CGI, sample programs, and more. You must have Internet access to view the book.
Your IBM HTTP Server allows you to configure three things related to CGI: v CGI settings
v Environment variables v Persistent CGI
You can also use server-side includes to insert information into CGI programs and HTML documents.
Configuring your CGI settings
The CGI settings control how your server handles conversions between EBCDIC and ASCII for CGI input and output. The value specified here is the default conversion mode for the server and can be overridden by an optional parameter on the Exec or Service directive on the Request Routing form. If the server is configured to convert between ASCII and EBCDIC, entity bodies with text/* or application/x-www-form-url encoded Content-Types will be checked for a charset tag. If found, the server will convert the corresponding ASCII CCSID to the EBCDIC CCSID of the job. If not found, the server will use the value of the DefaultNetCCSID configuration directive as the CCSID to convert from.
Use the Configuration and Administration forms to configure your CGI settings.
1. Click Configurations.
2. Click CGI.
3. Click CGI settings.
4. Complete the CGI settings form that is provided.
5. Click the Apply button.
You will receive a message that tells you whether or not the task completed successfully.
Configuring your environment variables
When the server runs a CGI program, it passes information about the request and about the server itself to the CGI program using environment variables. You can perform this task to specify which environment variables you want your CGI programs to inherit and which ones you do not want your CGI programs to inherit. A list of CGI environment variables can be found in the IBM HTTP Server
Web Programming Guide . You must have Internet access to view this book. Use the Configuration and Administration forms to configure your environment variables.
1. Click Configurations.
2. Click CGI.
3. Click Environment variables.
4. Complete the Environment variables form that is provided.
5. Click the Apply button.
You will receive a message that tells you whether or not the task completed successfully.
Configuring persistent CGI
Persistent CGI is an extension to the CGI interface. It allows a CGI program to remain active across multiple browser requests and maintain a session with that client. This allows files to remain open, the state to be maintained, and long running database transactions to be committed or rolled-back based on end-user input.
You must write the AS/400 CGI program by using named activation groups which allows the program to remain active after returning to the server. The CGI program notifies the server it wants to remain persistent using the″Accept-HTSession″ CGI header as the first header it returns. This header defines the session ID associated with this instance of the CGI program and does not return to the browser.
Subsequent URL requests to this program must contain the session ID as the first parameter after the program name. The server uses this ID to route the request to that specific instance of the CGI program. The CGI program should regenerate this session ID for each request. We strongly recommend that you use Secure Sockets Layer (SSL) for persistent and secure business transaction processing.
Use the Configuration and Administration forms to configure persistent CGI.
1. Click Configurations.
2. Click CGI.
3. Click Persistent CGI.
4. Complete the Persistent CGI form that is provided.
5. Click the Apply button.
You will receive a message that tells you whether or not the task completed successfully.
Using server-side includes
Server-side includes enable you to insert information into CGI programs and HTML documents that the server sends to the client. You may do this processing of Web pages before the server sends the page to the client. The current date, the file size, and the last change date of a file are examples of the kind of information that you can include in Web pages you send to the client.
Before using server-side includes on your server, there are a few issues you should consider. One issue is performance. Performance can be significantly impacted when the server processes files while sending them. Another issue is security. Letting ordinary users process commands can be a security risk. Be very careful when you decide in which directories you use server-side includes.
You should also note that you cannot refer to files recursively. For example, if you are processing the file sleepy.html, and the program finds <—!#include
file=″sleepy.html″ –>, then the server doesn’t detect the error and the server loops until stopped. However, you can refer to other, separate files within files. For example, the file that you name sleepy.html could refer to a file that you name bashful.html. That same file bashful.html could refer to the file that you name dopey.html.
Use the Configuration and Administration forms to use server-side includes.
1. Click Configurations.
2. Click Basic.
3. Complete the Basic form that is provided, selecting a server-side include option.
4. Click the Apply button.
You will receive a message that tells you whether or not the task completed successfully.