[prev] [next] [top] [bottom] (1 out of 1)

          

Dynamic Documents

Dynamic documents are documents that appear to change while a user is viewing them. Using dynamic documents, you can display animations and run Java applets within the document. This section describes some techniques you'll use when creating dynamic documents. Specifically, this section discusses:

Client pull

With client pull, the browser refreshes a document after a specified interval has expired; however, the HTTP header of the document can specify an alternate URL for the browser to access when the refresh occurs. For example, doc1.html can load, wait three seconds and then load doc2.html, which pauses three seconds before loading doc3.html. In this way, a simple animation is created.

You can accomplish client pull in one of two ways:

When you use the META tag to implement client pull, specify the following values for its attributes:

In the following example, the META tag creates a special HTTP header field that implements a client pull animation. The animation shows three different views of a dog; these views, when loaded sequentially, simulate the dog running. The CONTENT attribute specifies that each view of the dog is displayed for three seconds.

The following code is contained in a file called spot1.html:

<HEAD>

                    <TITLE>See Spot Run</TITLE>

                    <META NAME="refresh"

                              CONTENT="3"; URL='http://www.homepage.com/spot2.html'">

</HEAD>

<BODY>

                    <IMG SRC="spot1.gif">

</BODY>

The file spot2.html contains the following information:

<HEAD>

                    <TITLE>See Spot Run</TITLE>

                    <META NAME="refre'h"`

                              CONTENT="3;URL="http://www.homepage.com/spot3.html">

</HEAD>

<BODY>

                    <IMG SRC="spot2.gif">

</BODY>

Similarly, the file spot3.html contains a reference to spot3.gif within an IMG tag and a reference back to spot1.html in the META tag.

When a user loads spot1.html, the file is displayed for three seconds. Then the second file, spot2.html is loaded. After three more seconds elapse, spot3.html is loaded by the browser.

Server push

With server push, the server sends new data to the browser after a specified interval has expired. For example, the server sends data which the browser displays; waits three seconds and then sends new data which the browser displays; and so forth. In this way, a simple animation is created.

You must create a CGI gateway program to implement a server push.

When you use server push, the HTTP connection is held open, and the server periodically sends new data to the browser. Client pull is an alternate way to create dynamic documents. With client pull, a new HTTP connection is made each time the browser refreshes the document. Client pull can be accomplished in HTML; it does not require CGI programming.

Server-parsed HTML

Server-parsed HTML is a set of special commands (embedded within an HTML comment) that a server processes before sending the HTML to the client.

Normally, the server sends HTML documents to clients without changing the contents of the files. However, you can configure a server to parse HTML files before sending them to clients. When the server parses a file, it replaces the parsed commands with other text. For example, you can tell the server to insert the date and time that the HTML file was last modified.

Server-parsed HTML is sometimes referred to as a server-side include because the include command provides a way to include a file in an HTML document. Ordinary HTML allows you to include an image file only, but with server-parsed HTML, you can include entire text files.

You should consult your server's documentation to see how it supports server-parsed HTML. Typically, servers will parse any file that has the extension .shtml instead of .html. The server replaces the parsed command with HTML text.

Server-parsed HTML commands appear within HTML comment tags. The format for a command is:

<!--#command name="value1" name2="value2" ...-->

For example, to include the date your HTML was last modified and saved, you could include the following line in your HTNL file:

<!--#echo var="LAST_MODIFIED"-->

When you use a comment tag to enclose server-parsed HTML, you cannot enclose a comment within it. For example, the following statement is not valid:

<!--INCLUDE FILE="logo.gif" This is the corporate logo-->

Instead, you must use the following two lines:

<!--INCLUDE FILE="logo.gif"-->

<!--This is the corporate logo-->

Server-parsed HTML has many uses. Table 5.1 briefly describes some parsed HTML commands. See your server's documentation for more information on how it supports server-parsed HTML.