HTML preprocessor
(Server-Side Includes)

The HTML pre-processor is used to provide dynamic information inside of a standard HTML (HyperText Markup Language) document. The pre-processor is a script, run by the WWW server, which takes the requested document as input and returns a standard HTML document for the server to send to the client. The script scans the input document for special pre-processor directives, which are replaced by dynamic data based upon the particular directive.

In order for these directives to be parsed by the server, you will have to end your source files with either the extension .htmlx or .htx. These file extensions tell the server that it should parse the HTML source code for these directives. Also note that since these directives "pull" in other text that you can not view the directives themselves while viewing the source code from a web browser (the directives have already been replaced with the requested text).

Directive syntax

The syntax follows closely that used by the NCSA httpd WWW server, although not as many directives are supported (yet). The directive is enclosed within an HTML comment and takes the form:
<!--#command [[tag="value"] ...]-->
The command and tag keywords are case insensitive. The tag value may or may not be case sensitive, depending upon the command/tag. Generally the effect of a command is to produce additional text to be inserted in the document.

Directive commands

BEGIN part-name
The BEGIN directive marks the start of a region that may be selectively included with a part-qualified INCLUDE directive. A single BEGIN or END directive may specifiy multiple part names to begin or end at that point

ECHO
The ECHO command inserts special variables in the stream.


ACCESSES[;#]
Number of times document accessed. If you specify ";#" replacing the # with a number, the counter will be reset to 0. To reset the counter again, specify a different number. The access count is saved in the file www_root:[000000]accesses.dat.

ACCESSES_ORDINAL[;#]
Number of times document accessed with an ordinal suffix (e.g. 1st, 2nd, etc.)

DATE_LOCAL[=fmt]
Current system time

DOCUMENT_NAME
Filename (sans path) of current document

GETENV=symbol
Value of specified DCL symbol or logical

HW_NAME
Hardware model number

LAST_MODIFIED[=fmt]
Last-modified time of current document

SERVER_NAME
Hostname of current server

SERVER_VERSION
Server software version string

VMS_VERSION
Operating system version number

END part-name
The END directive marks the end of a region started by a previous BEGIN directive (see BEGIN). A file may specify more than one region with matching BEGIN/END pairs.

FLASTMOD
The FLASTMOD command inserts the file modification date of a specified file at the current point in the document being pre-processed.

If the preprocessor executable was built using the DEC C compiler, you can follow the file="fname" or virtual="path" tag with and fmt="fmt-str" tag. If a format string is specified, the date is formatted using strftime() rather than ctime(). The specified format is used as the format string for a call to strftime()

FSIZE
The FSIZE command inserts the file size in bytes (as best as can be determined) of a specified file at the current point in the document being pre-processed.

INCLUDE
The INCLUDE command inserts the content of another document at the current point in the document being pre-processed. Optionally, you may specify an part tag and name and only the named regions (see BEGIN and END directives) in the file will be inserted.

Examples

Including a file
<!--#include file="preproc-include.html"-->
<!--#include file="preproc-include.html" part="thisonly"-->
<!--#include virtual="/computing/webdevelop/preproc-include.html"-->

file: This is text from another file named "preproc-include.htm".
file/part: text from another file
virtual: This is text from another file named "preproc-include.htm".

Specifying parts
This is <!--#begin "thisonly"--> text from another file <!--#end "thisonly"--> named "preproc-include.htm".

File attributes
<!--#fsize file="preproc-include.htm"-->
<!--#flastmod file="preproc-include.htm" fmt="%I:%M:%S %p"-->
<!--#flastmod virtual="/computing/webdevelop/preproc-include.htm" fmt="%I:%M:%S %p"-->

Fsize: 108
Flastmod date: Wed Aug 3 19:02:38 2005
Flastmod (%I:%M:%S %p): 07:02:38 PM

Current document attributes
<!--#echo var="DOCUMENT_NAME"-->
<!--#echo var="LAST_MODIFIED[=%A, %B %d, %Y %I:%M:%S %p]"-->
<!--#echo var="ACCESSES;7"-->
<!--#echo var="ACCESSES_ORDINAL;7"-->

Document name: preproc.htx
Last modified: Wed Apr 26 09:53:46 2006
Last modified (%A, %B %d, %Y %I:%M:%S %p): Wednesday, April 26, 2006 09:53:46 AM
Accesses: 82,382
Accesses ordinal: 82,382nd access

Current time
<!--#echo var="DATE_LOCAL"--> 20-MAR-2010 15:52:33.81
<!--#echo var="DATE_LOCAL=%B %d, %Y %I:%M:%S %p"--> March 20, 2010 04:52:33 PM

Miscellaneous echo vars
<!--#echo= var="GETENV=SYS$REM_ID"--> ()
<!--#echo var="SERVER_NAME"-->
<!--#echo var="HW_NAME"-->
<!--#echo var="SERVER_VERSION"-->
<!--#echo var="VMS_VERSION"-->

Host uweb.txstate.edu is a AlphaServer 4100 5/600 8MB running the OSU/3.10a;Multinet under VMS V7.3-2

Locally modified from the original source of David Jones, Ohio State University


Texas State | Technology Resources