image\howbutt.gifWorking with Server Side Includes

Server-Side Includes (SSI) programs are used by an HTTP server to dynamically generate data for a Web page. An SSI program is executed before the HTTP server sends the HTML document to the HTTP client. You should use an SSI program when you have to process data before it is sent to the HTTP client. In contrast, CGI scripts are executed after the HTTP server sends the HTML document to the HTTP client. For information about CGI script, see "Working with CGI Script." An SSI program can be written in the same languages as CGI scripts. You can use SSI programs to add features, such as a hit counter, to your Web page. A hit counter keeps track of how many HTTP clients access a Web site.

To use SSI programs, you must configure the HTTP server to support parsing. Parsing lets an HTTP server search an HTML document for SSI directives. SSI directives are HTML tags that are included in the HTML code. To configure the HTTP server to accept parsing, you must make sure that the XBitHack directive, located in the srm.conf file, is set to on. For information about the XBitHack directive, see "Using the srm configuration file." You must also ensure that the Options directive, located in the access.conf file, supports the Includes value. This value informs the HTTP server to accept SSI directives. For information about the Options directive, see the "Using the access configuration file."

After you have configured all the necessary configuration files, you must add SSI directives to the HTML code. The syntax for an SSI directive is:

<!--#command argument = "value"-->

The following three commands specify different SSI directives:

You can create a hit counter using the Perl language and insert it in HTML code as an SSI directive. You must save the Perl program with a .cgi file extension. You can call the .cgi file by using the exec command. For example, you can call the counter.cgi file by adding the following SSI directive into your HTML code:

<!--#exec cgi="/cgi-bin/counter.cgi"-->

This line of code is executed before the HTTP server sends the HTML document to the HTTP client, and the result is displayed to the user.