A Complete Guide to Web Design

(やまだぃちぅ) #1

XSSI 255


Server Side
Includes

XSSI


Web Design in a Nutshell, eMatter Edition

Using Environment Variables


In the example in the previous section, the information placed in the document
was prepared ahead of time and saved in a file on the server for future use.


Another type of information that can be used by an SSI element isenvironment
variables. These are bits of information that the operating system (or the HTTP
server) always keeps track of and makes available for use by CGI programs and
SSI. The current date and time, the modification times of local files, and the user’s
browser version are all examples of environment variables. To use one in an SSI,
call it by its specific variable name (DATE_LOCAL,LASTMODIFIED, andHTTP
USER_AGENT, respectively, for the above examples) in the command. Note that
variable names vary for different server software.


Example: Printing the Date and Time


Let’s look at a very simple example of how environment variables work. In the
following example, we’ll display the current date and time on the web page using
theechoelement (which prints a specified variable to the screen) and theDATE_
LOCAL variable. If I put the following SSI command in my HTML source:


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

the server will print the following in its place:


Thursday, 02-Jul-98 20:10:24 EST

If the date and time format looks a little dry to you, you can change
it using theconfigelement and SSI time formats as explained later
in this chapter.

XSSI


If your server is running Apache Version 1.2 or higher, you can take advantage of
XSSI (eXtended Server Side Includes), which provides more advanced command
functions (and, consequently, uses code that is a bit more complicated for non-
programmer-types.)


This section presents a brief overview of features unique to XSSI. For the nitty-
gritty how-to information, see the Apache 1.3mod_includedocumentation at
http://www.apache.org/docs/mod/mod_include.html. There are several good arti-
cles on XSSI available on the WebMonkey site (http://www.webmonkey.com—look
for “backend”), which provide good explanations and examples of real-world
implementations of XSSI.


Flow Control Elements


Flow control elements are a set of if/else commands (similar to if statements used
in a programming language) that allow authors to create conditional commands.
Using flow control elements, authors can make documents display differently

Free download pdf