Database Reference
In-Depth Information
Web
Clients
INTERNET
Enterprise
Database
HTML
Documents
Server
CGI
Gateway
Other Data
Types
Figure 19-7
The CGI methodology.
browser points to a CGI script, then the Web server prepares certain environment
variables to indicate the state of the server, directs the browser input to the script's
STDIN, and launches the script. At the completion of its execution, the script places
its output in its STDOUT. The server passes on the output in the script's STDOUT
to the browser. STDIN and STDOUT are mnemonics for standard input and stan-
dard output, two predefined data stream or file handlers for each process. The CGI
specification calls for the Web server to pass information to a script through its
STDIN and to receive information from a script through its STDOUT.
Just one more detail about the information sent back from the execution of the
CGI script is worthwhile to note. The server does not know what type of output is
being sent to the browser from the execution of the CGI script. The CGI script could
have created a plain text file, a text file with graphics, an image file, and so on. This
information about the nature of the output must be communicated to the browser.
So a CGI script includes a header with information about the type of page contents.
How CGI works Let us consider how CGI applies to a Web environment and
trace the execution of a Web transaction.
Here are the broad steps:
1. The browser displays an HTML page containing an input form.
2. The user enters data into the form and clicks the submit button.
3. Sometimes, a script in the browser itself may perform client-side editing and
validation of the data filled into the form.
4. The browser decodes the URL and contacts the server.
Search WWH ::




Custom Search