Sun Java System Web Server 6.1 SP9 Programmer's Guide

Using Server-side HTML Commands

This section describes the HTML commands for including server-parsed tags in HTML files. These commands are embedded into HTML files, which are processed by the built-in SAF parse-html.

The server replaces each command with data determined by the command and its attributes.

The format for a command is:

<!--#command attribute1 attribute2 <Body>... -->

The format for each attribute is a name-value pair such as:

name="value"

Commands and attribute names should be in lower case.

The commands are hidden within HTML comments so they are ignored if not parsed by the server. The standard server-side commands are listed below, and described in this section:

config

The config command initializes the format for other commands.

Example

<!--#config timefmt="%r %a %b %e, %Y" sizefmt="abbrev"-->

This sets the date format to a value such as 08:23:15 AM Wed Apr 15, 1996, and the file size format to the number of KB or MB of characters used by the file.

include

The include command inserts a file into the parsed file. You can nest files by including another parsed file, which then includes another file, and so on. The client requesting the parsed document must also have access to the included file if your server uses access control for the directories in which they reside.

In Sun Java System Web Server 6.1, you can use the include command with the virtual attribute to include a CGI program file. You must also use an exec command to execute the CGI program.

Example

<!--#include file="bottle.gif"-->

echo

The echo command inserts the value of an environment variable. The var attribute specifies the environment variable to insert. If the variable is not found, “(none)” is inserted. For a list of environment variables, see Environment Variables in Server-side HTML Commands.

Example

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

fsize

The fsize command sends the size of a file. The attributes are the same as those for the include command (virtual and file). The file size format is determined by the sizefmt attribute in the config command.

Example

<!--#fsize file="bottle.gif"-->

flastmod

The flastmod command prints the date a file was last modified. The attributes are the same as those for the include command (virtual and file). The date format is determined by the timefmt attribute in the config command.

Example

<!--#flastmod file="bottle.gif"-->

exec

The exec command runs a shell command or CGI program.

Example

<!--#exec cgi="workit.pl"-->