Previous | Contents | Index |
After processing an HTTP request from a client, the result of processing the command is sent back as an HTTP response to the client. The format of the response is governed by formatting files specified in the command from the client. That is, the request from the client includes the names of formatting files on the CGI server system that are to be used to format the response sent back to the client. On OpenVMS systems, these files must reside in the PMDF_ROOT:[WWW.POPSTORE]
directory; on UNIX and NT systems, these files must reside in the /pmdf/www/popstore/
directory tree.
The formatting files can contain text to be copied verbatim into the HTTP response as well as directives to substitute in values associated with the results of a particular command. There are three basic types of formatting files: success, error, and command-specific files.
After the CGI parses a request and executes it, the results of the operation are sent back to the HTTP client using the following formatting steps:
%s
is replaced with the formatted data generated in the first step. The
HTTP response sent back to the client will have an HTTP 200 status code.
%s
is replaced with the output, if any, of the first step as well as any
error messages. The HTTP response sent back to the client will have an
HTTP 200 status code.
In the command-specific formatting files, command-specific substitution strings can appear. These strings all begin with the percent character, %
. When such a string is encountered, the value it references is
substituted into the HTTP response. For instance, the formatting file
%none{No users found matching your search criterion} %first{<TABLE><TR><TH>Username<TH>Messages} <TR><TD>%username<TD>%message_count %last{</TABLE>} |
list_users
command to produce an HTML table of the popstore users and how many
messages each have stored; e.g.,
<TABLE><TR><TH>Username<TH>Messages <TR><TD>asmith<TD>11 <TR><TD>jdoe<TD>7 <TR><TD>mfreed<TD>8 <TR><TD>wrobinson<TD>12 <TR><TD>zsmith<TD>0 </TABLE> |
In the tables describing each substitution string, the type of data associated with the substitution string is stated. These types are:
Type | Description |
---|---|
int | Signed integer |
float | Single precision floating point number |
string | ASCII text string |
uint | Unsigned integer |
{}
, and appending them to the substitution string. For instance,
%quota_used{%.1f} Kbyte%s |
%quota_used
to a single digit of precision after the decimal point.
Five substitution strings, %first
, %last
, %!first
, %!last
, and %none
, deserve special attention. These first four strings substitute into the output specific text when formatting, respectively, the first, the last, not the first, or not the last instance of the data to be formatted. The text to be substituted in must be enclosed in braces, {}
, following the substitution string.3 For example, suppose
that a list of popstore users is to be formatted using the following
formatting file:
%first{<TABLE>} <TD>%username %last{</TABLE>} |
TABLE
> will be output followed by the username (%username
). When information for the last account is formatted, the text </TABLE
> will be output following the username.
The %none
substitution string supplies text to output when there are no instances
of the collected data to display. For example, when there are no
messages to list for a given user account.
3 At present, substitution strings appearing within the text to be substituted are ignored and treated as literal text. |
Previous | Next | Contents | Index |