Database Reference
In-Depth Information
INTEGRATION APPROACHES
We have reviewed the motivation for integrating Web and database technologies.
We have explored architectural options. We have considered the advantages and
disadvantages. Now that you are convinced of the importance of the integration, let
us look at the feasibility of such an integration. We will now examine the leading
approaches for Web-database integration.
Common Gateway Interface (CGI)
You are now familiar with the basic functionalities of the browser and the Web
server. The browser can request for Web documents stored in files, and the server
can dispense these precoded HTML documents to the browser. The Web server can
read files but cannot write to them. The Web server is intended to read HTML doc-
uments but not data from multiple types of sources. Apart from providing static web
pages, the Web server cannot customize web pages or satisfy a request for data from
a database.
Consider a simple Web application. A simple form is presented to the browser
for the user to fill in the name and address. All that is required is for the name and
address to be stored at the website and a confirmation message sent back to the
user addressing him or her by the first name. The Web server by itself is not equipped
to complete even such a simple transaction.
Some other interface is needed to receive the name and address details from the
browser, store those details in a database, embed the user's first name in a web page,
and send back the page to the user. A program is needed to interface with the data-
base and store the name and address. The Common Gateway Interface (CGI) is
such an interface and a specification for programs to accomplish such tasks.
What is CGI? CGI is a standard method for interfacing Web applications to
sources of data. Programs written under CGI specification can retrieve web pages,
access database records, build web pages on-the-fly, send e-mails, and so on. A CGI
program can read and write data files; the Web server can only read them. A browser
sends information to the server, and the server passes on the information to a CGI
program that sends its output to the server, which in turn sends the requested infor-
mation to the browser. A CGI program does not communicate with the browser
directly but through the Web server. CGI is a standard method for a Web server
and a CGI program to communicate. CGI defines the standard for a browser to
communicate through the server with a CGI program executing on the server
machine.
Figure 19-7 illustrates the CGI methodology. Note how CGI provides a generic,
standard method to interface with multiple types of data sources.
A CGI program may be written in any of the different programming languages
such as C/C++ or Perl. With regard to processing logic, a CGI program is just like
any other program. The essential difference lies in the way a CGI program receives
information from the Web server and sends information back to the server. CGI
programs are generally referred to as scripts.
When a URL from the browser points to a HTML page in a file, the Web server
fetches that page and sends it to the browser. On the other hand, if a URL points
to a program, the server starts that program. Let us say that the URL from the
Search WWH ::




Custom Search