LIS 525 - Server Side Includes

What Are SSIs?

A Server Side Include (SSI) is a type of HTML comment that directs the server to generate data dynamically whenever the Web page is requested. The basic format of an SSI is
    <!--#command tag="value"...--> 

Different servers support different SSIs in different ways, but many commands, such as include and exec, are widely supported.

Web pages that contain SSIs often need to have the extension .shtml as a sign to the server that they need to be processed before being sent to the client. An Apache server can be configured (with the XBitHack on directive) to look for SSIs in regular HTML files which have execute permission.

The command include asks the server to insert the contents of another file. Possible advantages of this include the following.

SSIs can also be used to insert the results of executing programs.

Some disadvantages of SSIs include the following.

Examples of SSI Treatment by Servers

Look at ssi.shtml in your browser. If you are viewing a local copy, you will just see
The following are CGI variables for the server:

The following are CGI variables for the browser:

The following executes a command in LINUX to get the directory:

The following shows the contents of file ssiincl.txt:

On the other hand, if you requested a copy on the FIMS intranet you would see something like

The following are CGI variables for the server:

The following are CGI variables for the browser:

The following executes a command in LINUX to get the directory:

The CMD option is not enabled for #EXEC calls

The following shows the contents of file ssiincl.txt: HTTP/1.1 404 Object Not Found Server: Microsoft-IIS/5.0 Date: Fri, 20 Apr 2007 14:10:31 GMT MicrosoftOfficeWebServer: 5.0_Collab X-Powered-By: ASP.NET Connection: close Content-Type: text/html

404 Object Not Found

The exec call would not work because the intranet server is not running Linux. The include command would not work because the server has a problem dealing with the virtual tag; if the (non-preferred) file tag had been used instead, the contents of the file would be correctly included.

If you request the same file from the course's public Web site (http://publish.uwo.ca/~craven/525/ssi.shtml), you will get a server error page; the server is apparently trying to handle the SSI, but is messing up in some fatal way.

For More Information


Home

Last updated April 25, 2007.
This page maintained by Prof. Tim Craven
E-mail (text/plain only): craven@uwo.ca
Faculty of Information and Media Studies
University of Western Ontario,
London, Ontario
Canada, N6A 5B7