chapter 33 cgi technology for dynamic web documents there are two alternative forms of retrieving...
TRANSCRIPT
![Page 1: Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,](https://reader036.vdocument.in/reader036/viewer/2022072011/56649e305503460f94b20ce7/html5/thumbnails/1.jpg)
Chapter 33 CGI Technology Chapter 33 CGI Technology for Dynamic Web Documents for Dynamic Web Documents
There are two alternative forms of retrieving web documents.
Instead of retrieving static HTML documents, these alternative forms allow computer programs to control the contents of a document dynamically.
In one form, a Web server runs an auxiliary program (CGI program) to create a document whenever a request arrives from a browser.
In the other form, a server provides the browser with a computer program (JAVA).
![Page 2: Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,](https://reader036.vdocument.in/reader036/viewer/2022072011/56649e305503460f94b20ce7/html5/thumbnails/2.jpg)
Three types of Web Three types of Web documents documents
Static, dynamic, and activecategorized depending on when the
information in the document changes
![Page 3: Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,](https://reader036.vdocument.in/reader036/viewer/2022072011/56649e305503460f94b20ce7/html5/thumbnails/3.jpg)
Static DocumentsStatic Documents
content of document is determined when document is written and remains unchanged until author revises document
![Page 4: Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,](https://reader036.vdocument.in/reader036/viewer/2022072011/56649e305503460f94b20ce7/html5/thumbnails/4.jpg)
Dynamic DocumentsDynamic Documents
document does not exist in a predefined form. document is created by a web server whenever a
browser requests the document. When a request arrives, the Web server runs an
application program that creates the dynamic document.
The server returns the output of the program as a response to the browser.
The contents of a dynamic document can vary whenever a server receives a request for the document
![Page 5: Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,](https://reader036.vdocument.in/reader036/viewer/2022072011/56649e305503460f94b20ce7/html5/thumbnails/5.jpg)
Active DocumentActive Document
consists of a computer program that understands how to compute and display values.
When a browser request an active document, the server returns a copy of the program that the browser must run locally.
Information displayed can change after the document has been loaded into a browser.
![Page 6: Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,](https://reader036.vdocument.in/reader036/viewer/2022072011/56649e305503460f94b20ce7/html5/thumbnails/6.jpg)
Comparison of Document TypesComparison of Document TypesPro Con
Static simple, fast, reliable inflexible
Dynamic able to report current information eg. Current stock price & weather conditions
increased cost and inability to display changing information after browser receives copy of dynamic document. Ie. Document starts to age (stale) after browser gets document
Active able to update information continuously without user interaction (eg. Animation or updated stock prices
added cost of creating and running such documents.
![Page 7: Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,](https://reader036.vdocument.in/reader036/viewer/2022072011/56649e305503460f94b20ce7/html5/thumbnails/7.jpg)
Common Gateway Interface Common Gateway Interface (CGI) (CGI)
Standard is used for building dynamic Web documents.
specifies how a server interacts with an application program that implements a dynamic document.
The application is called a CGI program. CGI does not specify a particular programming
language ( eg. could be C, Perl , or Unix shell (fig 33.1))
![Page 8: Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,](https://reader036.vdocument.in/reader036/viewer/2022072011/56649e305503460f94b20ce7/html5/thumbnails/8.jpg)
CGI program outputCGI program output
can be an HTML document, a plain text file, or a graphics image.
A header (eg. Content-type: text/html ) (Content-type: text/plain) consists of line(s) of text describing the document type followed by a blank line, or a header can specify that the requested document is at a different location (eg. Location: /new/bar.txt <blank line>)
![Page 9: Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,](https://reader036.vdocument.in/reader036/viewer/2022072011/56649e305503460f94b20ce7/html5/thumbnails/9.jpg)
CGI application supportCGI application support
A server that is capable of running CGI programs must be configured before it can invoke a CGI program or script.
When the a browser contacts the server and request the specified URL, the server runs the CGI program
![Page 10: Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,](https://reader036.vdocument.in/reader036/viewer/2022072011/56649e305503460f94b20ce7/html5/thumbnails/10.jpg)
Parameters and Environment Parameters and Environment VariablesVariables
browser can pass parameters to a CGI program via URL. If the prefix of the URL corresponds to a CGI program, the
server invokes the CGI program and passes the suffix of the URL as an argument.
The question mark character (?) in the URL separates the prefix from the suffix.
The server uses its configuration information to map the prefix to a particular CGI program.
The server passes everything after the question mark as an argument to the CGI program via environment variables instead of via command line
![Page 11: Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,](https://reader036.vdocument.in/reader036/viewer/2022072011/56649e305503460f94b20ce7/html5/thumbnails/11.jpg)
Environment Variables Environment Variables inherited by a CGI programinherited by a CGI program
SERVER_NAME – contains domain name of computer running web server
GATEWAY_INTERFACE – contains version of CGI software server is using
SCRIPT_NAME – the path in the URL after the server name.
QUERY_STRING – contains information following “?” in the URL
REMOTE_ADDR – contains IP address of the computer running the browser
that sent the request.
![Page 12: Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,](https://reader036.vdocument.in/reader036/viewer/2022072011/56649e305503460f94b20ce7/html5/thumbnails/12.jpg)
State InformationState Information Information preserved from one invocation of a CGI
program to the next – helps avoid having a user answer questions repeatedly
when specifying additional requests. CGI program saves information between requests
(state information) via one of two methods for info that must be maintained across invocations
of a browser, the CGI program uses files for long term storage (fig 33.3)
for info that must be kept only while a browser is running, a dynamic document program encodes such information in URLs that appear in the hypertext links in the document (fig 33.4)
![Page 13: Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,](https://reader036.vdocument.in/reader036/viewer/2022072011/56649e305503460f94b20ce7/html5/thumbnails/13.jpg)
Server-Side Scripting Server-Side Scripting TechnologiesTechnologies
Alternative dynamic document technologies used when only a small portion of web page needs to be changed.
Interpreters built into web servers that can make small changes to a predefined template containing both HTML and scripts
Regular HTML passes through unchanged Script information is replaced with output from
interpreting the script ASP, JSP, PHP, Cold Fusion