Dynamic Web Pages
A dynamic document is produced by a program that can receive
input from a user and modify the Web page based on that input. A typical
mechanism for communication between a user's browser and a Web server is
called the Common Gateway Interface (CGI). Altogether, the Common
Gateway Interface (CGI) is a set of conventions, supported by software,
that facilitate the writing of programs that generate World Wide Web
documents. CGI programs can be written in almost any programming language;
naturally, though, we'll use Java.
With CGI programming, the sequence of events for Web interaction has an
extra step:
-
Within a Web browser, you type a URL.
-
Your browser sends a request to the server for that address.
-
The server finds the file on a disk drive.
-
The server retrieves the file from the disk and notes that the file
identifies a program to run.
-
The server runs the program, which produces an HTML document.
-
The first line of the HTML document tells both the Web server and your
browser that this will be a text-based html document, and thus clarifies
how both the server and browser will communicate.
-
The rest of the HTML document contains formatting instructions and text for
display.
-
The server sends the newly-produced HTML document back to your browser.
-
Your browser interprets the file and displays it on your screen.
This sequence of events is illustrated in the following diagram.