PRIMUS Home Page PRIMUS Support
USING SERVER SIDE INCLUDES





ACCOUNT MANAGER

--

--

 

Normally, web documents are sent to the browser of the person who requests them (the client) as regular text files. HTML tags in the document are parsed by the browser of the client to format the page.

In order to include dynamic content in the documents that can change each time the document is served, a web server can be told to parse, or look for and execute, commands that are present in the document before it is sent to the client's browser.

Some of the things that these commands to the server can do are:

  • print the current date and time or the date and time that the file was last modified
  • include the contents of a particular file
  • execute a cgi script

Using Server Side Includes at PRIMUS

PRIMUS' web servers are configured to parse any documents that are named with the file extension .shtml.

Commands to the server always conform to the following format:

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

Below are some useful commands that can be included within .shtml documents.

include

The include command inserts a text file into the parsed file. This can be a CGI script if the CGI sc ript outputs HTML. It can also just be another HTML document. The permissions on the included file must be set to allow access to the user requesting it.

The include command can be used in one of two ways:
 <!--#include virtual="/path/to/file/to/be/included.html"--> 
or <!--#include file="relative/path/from/current/directory"--> 

echo

The echo command prints data from a specific variable. For example, you can print the date at the time (local time zone) that the document is loaded. The command looks like this:

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

(var stands for variable)

and will return the following output:

Wednesday, 20-Aug-2008 10:10:15 EDT

Other values you can use for the var attribute include:

  • DATE_GMT - same as DATE_LOCAL but in Greenwich Mean Time
  • DOCUMENT_NAME - name of current document
  • DOCUMENT_URI - virtual path to current document
  • LAST_MODIFIED - date that current file was last modified

as well as any variables in the CGI Variables set.

fsize

The fsize command prints the size of a given file. The attributes accepted for fsize are the sam e as those used for the include command. For example, to print the file size of this document, I would use the following command:
 <!--#fsize 
file="ssi.html"--> 

the output would look like this:

5k

flastmod

flastmod prints the date that a given file was last modified. The attributes are the same as those f or include and fsize. To see when this document was last modified, you would use a command like thi s:

 <!--#flastmod file="ssi.html"--> 

to get the following output:

Thursday, 31-Oct-2002 13:52:10 EST



Back to Shared Hosting Support

2004 PRIMUS All Rights Reserved
PRIMUS Home Page PRIMUS Support