Server Side Includes

NOTE : Server Side Includes are HTTP server specific.

Server side includes (SSI) applied to an HTML document, provide for interactive real-time features such as echoing current time, conditional execution based on logical comparisons, querying or updating a database, sending an e-mail etc., with no programming or CGI scripts.

As the SSI specification is continually updated, what is presented here is just a taster of SSI usage. For the complete and most recent documentation visit Yahoo's Server Side Includes (SSI).

The possible SSI tags that are currently useable are :

'echo'Allows the insertion of certain variables into a HTML document
'include'Allows the insertion of files into HTML documents
'fsize'Allows for the insertion of a file's size in a HTML document
'flastmod'Allows for the insertion of a file's last modification date into a HTML document
'exec'Executes an external executable file
'config'Allows setting of various options for other SSI tags
'odbc'Allows the querying and updating of external ODBC databases
'email'Sends an e-mail whenever a page is accessed or a form is submitted
'if'Allows conditional execution of other SSI tags and conditional printing of documents based on logical comparisons
'goto'Makes a jump to a pre-defined SSI 'label'
'label'Provides a target for 'goto' jumps
'break'Terminates the HTML document at any point

Some brief examples
'echo'

The 'echo' tag is used for inserting certain variable data into a HTML document. For example :

You are using a <!--#echo var="HTTP_USER_AGENT" --> browser

would translate in the document as being (for the sake of this example, the browser is Internet Explorer 3.0 for Windows 95) :

You are using a Mozilla/2.0 (compatible; MSIE 3.0A; Windows 95) browser.

The various different var values that this tag accepts are described fully in the SSI specification.

'include'
The 'include' tag provides the answer to one of the most common questions within HTML discussions. Namely, ‘How can I insert a file into an HTML page?’

By using the following in an HTML document :

<!--#include virtual="/includes/page.htm"-->

would insert the contents of the file /includes/page.htm into the current HTML document at the insertion point.

'email'
The 'email' tag can be used to send an e-mail message whenever (for example) a page is accessed, or some form data sent to a remote site.

Using the following in a document :

<!--#email tohost="htmlib.com" message="Thanks for the HTMLib" toaddress="response@htmlib.com" subject="The HTMLib" -->

would cause the mail message (specified in the message attribute) to the address specified in the toaddress attribute (if they actually existed.)

As can be seen, the possibilities of SSI tags are extensive and it provides a mechanism for performing many common actions that would normally require CGI scripting. As said above, SSI use is server specific. If you wish to employ SSI tags in your HTML, consult your server maintainer to see if it is possible and also see Yahoo's Server Side Includes (SSI).