Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,

Similar presentations


Presentation on theme: "Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,"— Presentation transcript:

1 Chapter 33 CGI Technology 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).

2 Three types of Web documents Static, dynamic, and active categorized depending on when the information in the document changes

3 Static Documents content of document is determined when document is written and remains unchanged until author revises document

4 Dynamic 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

5 Active 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.

6 Comparison of Document Types ProCon Static simple, fast, reliableinflexible 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.

7 Common Gateway Interface (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))(fig 33.1)

8 CGI 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 )

9 CGI 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

10 Parameters and Environment Variables 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

11 Environment Variables inherited 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.

12 State 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)(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)(fig 33.4)

13 Server-Side Scripting Technologies 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


Download ppt "Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,"

Similar presentations


Ads by Google