Lonestar Home

Search Lonestar


Texas.Net (Business)

Contact Info

Account Info
Change Password
Add Popmail
Spam Filter

Internet Alerts
Virus Alerts
Security Alerts
Hoax Alerts
Spam Email

General Settings
Windows Setup
Macintosh Setup
Other OS Setup
Internet Software
Email Setup
Usenet News Setup
Web Page Setup
Modem Tips

E-mail Support
Trouble Ticket
Billing Ticket


Parental Controls

Terms & Conditions
Acceptable Use
Privacy Policy
Legal Text
English Text

Customer Pages

Internet Basics
World-Wide Web

Staff Picks
Windows 98
Kids' Links

Using Server-Side Includes (SSI)

A server-side include (SSI, for short) is a command to the web server embedded in the HTML. SSIs allow the creation of semi-dynamic web pages without the hassle of writing and maintaining of CGI scripts. Below are a few simple and useful SSI examples that you can use on your personal web page. If you'd like more advanced uses of SSIs, visit Apache's web site and read through their server documentation on SSIs.

NOTE: This document is provided as-is by Texas.Net. SSIs are in no way supported by technical support or the Texas.Net helpdesk. Because SSIs require that the server be configured to parse through .html files, the ability to use SSIs may be removed at any time without warning.

Basics Of SSIs
Before we get to the examples, it'd be first helpful to know what an SSI looks like. SSIs always take the form:

<!--#element attribute=value -->

When they appear in your code, they are completely replaced by whatever the server outputs (whether it be text from another HTML page or output from code or the result of a variable evaluation), so you won't be able to tell if their in your source code simply by viewing that code from your browser. When an SSI fails, you will see the line:

error processing this directive

Sometimes, however, it may be hidden, especially if the output was supposed to generate part of a table, in which case, nothing would appear. The important thing to remember when using SSIs is that they must all be one line. You can't have line breaks separating the various portions of an SSI or it will simply be outputted to the browser that way (they won't appear in the browser though because they look like comments).

Displaying the "Last Modified" Date
To let your viewers know the last time you updated your web page, you can have the server print out the LAST_MODIFIED server variable. For example, this document was last updated Thursday, 03-Jun-2004 16:36:28 CDT. The line of HTML that produced this value is:

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

You can put this line anywhere, although most people usually put this in the header or footer of the document. It's great for letting people know when you've last updated your web page.

A Consistent Look
When designing a site of many pages, you might want to make them all look alike, with a common opening header or some such. The Lonestar site is like this, where each page in a section has the same general look and feel of the other pages in that section. Rather than writing the same 70-100 lines of HTML code for the beginning of each page, we create a single document with a generic name like TOP.html and then use that document in all of our web pages with a line like:

<!--#include virtual="TOP.html" -->

This line will take the text from TOP.html and insert it wherever that SSI appears in our code, effectively transferring that entire block of HTML into our web page. With this, you can quickly create a site of numerous pages having, possibly, the same complex interface without hours of complex coding per page.

Variable Interpolation
In addition to LAST_MODIFIED, you can print out other variable values that Apache provides (DATE_GMT, DATE_LOCAL, DOCUMENT_NAME, and DOCUMENT_URI) as well as all of the environment variables and their values. Listed below are the environment variables and their current values.

Variable Value
DATE_GMT Monday, 25-Sep-2017 13:25:15 GMT
DATE_LOCAL Monday, 25-Sep-2017 08:25:15 CDT
DOCUMENT_NAME www_ssi.html
DOCUMENT_ROOT /web/lonestar/htdocs/home
DOCUMENT_URI /helpdesk/www_ssi.html
HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_ENCODING x-gzip, gzip, deflate
HTTP_IF_MODIFIED_SINCE Sat, 22 Jul 2017 10:50:14 GMT
LAST_MODIFIED Thursday, 03-Jun-2004 16:36:28 CDT
PATH /usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/ccs/bin:/usr/ucb:/usr/openwin/bin:/usr/opt/SUNWmd/sbin:/usr/proc/bin:/usr/opt/hpnp/bin:/usr/local/ssl/bin:/web/shared/ssl/ssl/bin
REQUEST_URI /helpdesk/www_ssi.html
SCRIPT_FILENAME /web/lonestar/cgi-bin/
SCRIPT_NAME /cgi-bin/
SCRIPT_URL /helpdesk/www_ssi.html
SERVER_SOFTWARE Apache/1.3.33 (Unix) FrontPage/ mod_perl/1.27
TZ US/Central
USER_NAME user#5888

Again, SSIs are not supported by Texas.Net. They are currently functioning due to our web server setup and may become inoperable at any time.
©1994-2005, Texas.Net, Inc. All rights reserved.