ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaie_5.4.0.1/rzag3ch1overview.htm

131 lines
8.4 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="topic" />
<meta name="DC.Title" content="Overview of CGI" />
<meta name="abstract" content="This topic provides information about CGI. Common Gateway Interface (CGI) is a standard, supported by almost all web servers, that defines how information is exchanged between a web server and an external program (CGI program)." />
<meta name="description" content="This topic provides information about CGI. Common Gateway Interface (CGI) is a standard, supported by almost all web servers, that defines how information is exchanged between a web server and an external program (CGI program)." />
<meta name="DC.Relation" scheme="URI" content="rzaieparcgi.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2002,2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2002,2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzag3ch1overview" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Overview of CGI</title>
</head>
<body id="rzag3ch1overview"><a name="rzag3ch1overview"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Overview of CGI</h1>
<div><p>This topic provides information about CGI. Common Gateway Interface
(CGI) is a standard, supported by almost all web servers, that defines how
information is exchanged between a web server and an external program (CGI
program). </p>
<p>The CGI specification dictates how CGI programs get their input and how
they produce any output. CGI programs process data that is received from browser
clients. For example, the client fills out a form and sends the information
back to the server. Then the server runs the CGI program. </p>
<p>Programs that are called by the server must conform to the server CGI interface
in order to run properly. We will describe this in further detail later in
this chapter. </p>
<p>The administrator controls which CGI programs the system can run by using
the server directives. The server recognizes a URL that contains a request
for a CGI program, commonly called a CGI script. Depending on the server directives,
the server calls that program on behalf of the client browser. </p>
<p>The server supports CGI programs that are written in C++, REXX, ILE C,
ILE RPG, and ILE COBOL. It also supports multi-thread CGI programs in all
of these languages capable of multiple threads.</p>
<p>You need to compile programs that are written in programming languages.
Compiled programs typically run faster than programs that are written in scripting
languages. On the other hand, those programs that are written in scripting
languages tend to be easier to write, maintain, and debug.</p>
<p>The functions and tasks that CGI programs can perform range from the simple
to the very advanced. In general, we call those that perform the simple tasks
CGI scripts because you do not compile them. We often call those that perform
complex tasks gateway programs. In this manual, we refer to both types as <dfn class="term">CGI
programs</dfn>.</p>
<p>Given the wide choice of languages and the variety of functions, the possible
uses for CGI programs seem almost endless. How you use them is up to you.
Once you understand the CGI specification, you will know how servers pass
input to CGI programs and how servers expect output.</p>
<p>There are many uses for CGI programs. Basically, you should design them
to handle dynamic information. Dynamic in this context refers to temporary
information that is created for a one-time use and not stored as a static
Web page. This information may be a document, an e-mail message, or the results
of a conversion program.</p>
<p>For detailed information about CGI APIs, see Chapter 8, “HTTP
Server Application Programming Interfaces” on page 51.</p>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzaieparcgi.htm" title="This topic provides information about Common Gateway Interfaces (CGI).">Common Gateway Interface</a></div>
</div>
</div><div class="nested1" xml:lang="en-us" id="cgianddynamicdocuments"><a name="cgianddynamicdocuments"><!-- --></a><h2 class="topictitle2">CGI and Dynamic Documents</h2>
<div><p>There are many types of files that exist on the web. Primarily they fall
into one of the following categories:</p>
<ul><li>Images</li>
<li>Multimedia</li>
<li>Programs</li>
<li>HTML documents</li>
</ul>
<p>Servers break HTML documents into two distinct types:</p>
<ul><li>Static</li>
<li>Dynamic</li>
</ul>
<p><dfn class="term">Static documents</dfn> exist in non-changing source form on the
web server. You should create <dfn class="term">Dynamic documents</dfn> as temporary
documents to satisfy a specific, individual request.</p>
<p>Consider the process of ″serving″ these two types of documents. Responding
to requests for static documents is fairly simple. For example, Jill User
accesses the Acme web server to get information on the Pro-Expert gas grill.
She clicks on Products, then on Grills, and finally on Pro-Expert. Each time
Jill clicks on a link, the web browser uses the URL that is attached to the
link to request a specific document from the web server. The server responds
by sending a copy of the document to Jills browser.</p>
<p>What if Jill decides that, she wants to search through the information
on the Acme web server for all documents that contain information on Acme
grills? Such information could consist of news articles, press releases, price
listings, and service agreements. This is a more difficult request to process.
This is not a request for an existing document. Instead, it is a request for
a dynamically generated list of documents that meet certain criteria. This
is where CGI comes in.</p>
<p>You can use a CGI program to parse the request and search through the documents
on your web server. You can also use it to create a list with hypertext links
to each of the documents that contain the specified word or string.</p>
</div>
</div>
<div class="nested1" xml:lang="en-us" id="usesforcgi"><a name="usesforcgi"><!-- --></a><h2 class="topictitle2">Uses for CGI</h2>
<div><p>HTML allows you to access resources on the Internet by using other protocols
that are specified in the URL. Examples of such protocols are <samp class="codeph">mailto</samp>, <samp class="codeph">ftp</samp>,
and <samp class="codeph">news</samp>. If you code a link with <samp class="codeph">mailto</samp> that
is followed by an e-mail address, the link will result in a generic mail form.</p>
<p>What if you wanted your customers to provide specific information, such
as how often they use the web? Or how they heard about your company? Rather
than using the generic <samp class="codeph">mailto</samp> form, you can create a form
that asks these questions and more. You can then use a CGI program to interpret
the information, include it in an e-mail message, and send it to the appropriate
person.</p>
<p>You do not need to limit CGI programs to processing search requests and
e-mail. You can use them for a wide variety of purposes. Basically, anytime
you want to take input from the reader and generate a response, you can use
a CGI program. The input may even be apparent to the reader. For example,
many people want to know how many other people have visited their home page.
You can create a CGI program that keeps track of the number of requests for
your home page. This program can display the new total each time someone links
to your home page.</p>
</div>
</div>
</body>
</html>