Using Server-Side HTML Commands

                                                                                                                                                                                                                                                                                                                                      Back to [Book]     [Topic]

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_ [Please define the ellipsis text entity] -->

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 Command

The config command initializes the format for other commands.

  • The errmsg attribute defines a message sent to the client when an error occurs while parsing the file. This error is also logged in the error log file.
  • The timefmt attribute determines the format of the date for the flastmod command. It uses the same format characters as the util_strftime function. The default time format is: "%A, %d-%b-%y %T". For more information about time formats, see the Time Formats.
  • The sizefmt attribute determines the format of the file size for the fsize command. It can have one of these values:
    • bytes to report file size as a whole number in the format 12,345,678.
    • abbrev (the default) to report file size as a number of KB or MB.

Example

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

This example sets the date format to a value such as 10:45:35 AM Wed Apr 21, 2006, and the file size format to the number of KBytes or MBytes of characters used by the file.

include Command

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 Web Server, 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.

  • The virtual attribute is the URI of a file on the server.
  • The file attribute is a relative path name from the current directory. It cannot contain elements such as ../ and it cannot be an absolute path.

Example

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

echo Command

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 Command

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 Command

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 Command

The exec command runs a shell command or CGI program.

  • The cmd attribute (UNIX only) runs a command using /bin/sh. You may include any special environment variables in the command.
  • The cgi attribute runs a CGI program and includes its output in the parsed file.

Example

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

Labels

java java Delete
server server Delete
sun sun Delete
webserver webserver Delete
application application Delete
system system Delete
webtier webtier Delete
guide guide Delete
webserver70 webserver70 Delete
sunjava sunjava Delete
+devguide +devguide Delete
developers developers Delete
web web Delete
developersguide developersguide Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact