Thursday, March 24, 2005

Server-side include commands for HTTP Server (powered by Apache) for Iseries

Server-side include commands for HTTP Server (powered by Apache)
HTTP Server (powered by Apache) SSI commands have the following format:

<--#command parameter="value -->
Note: There is a space before -->. The parameter value is normally enclosed in double quotes, but for compatibility with the HTTP Server (original), double quotes are not required.
The following describes the SSI commands for HTTP Server (powered by Apache).

echo
This command prints one of the SSI or API variables. Dates are printed using config timefmt. The attributes are:

var
Specifies an environment variable name or CGI environment variable name.
See the Environment variables on HTTP Server topic for a list of environment variables.
For example:


encoding
Specifies how the server encodes special characters contained in the variable. If set to none, no encoding is done. If set to url, then URL encoding (or %-encoding) is performed. If set to the default of entity, then entity encoding is performed.
For example:


exec
This command calls a CGI program. The attributes are:

cgi
Specifies the relative path and file name. For example:

fsize
This command prints the size of the specified file according to config sizefmt. The attributes are:

file
Specifies the relative path and file name. For example:

virtual
Specifies the relative path and file name using URL encoding. For example:

flastmod
This command prints the last modification date of the specified file according to config timefmt. The attributes are:

file
Specifies the relative path and file name. For example:

virtual
Specifies the relative path and file name using URL encoding. For example:

global
This command is the same as the set command.

include
This command inserts the text of another file. Included files can be nested. The attributes are:

file
Specifies the relative path and file name. For example:

virtual
Specifies the relative path and file name using URL encoding. For example:

printenv
This command prints all existing environment variables and their values. There are no attributes. For example:


set
This command sets the value of an environment variable. The attributes are:

var
Specifies an environment variable name.
See Environment variables on HTTP Server for a list of environment variables.

value
Specifies the value to assign to the environment variable name. For example:

If you want to insert a special character in a string, precede it with a \. For example:


Conditional commands
There are four conditional or flow control commands. The if command tests a value. If the value is true, then processing continues with the next line. If the value is not true then processing continues with an elif, else, or endif command. The elif and else commands are optional. The if and elif commands have a parameter of expr. The expr parameter contains the test condition. An endif command is required for every if command. For example:


You are using Internet Explorer.



You are using Netscape.



You are not using Internet Explorer or Netscape.



The expr parameter can have one of the following forms:

Condition Comments
string True if the string is not empty
string1 = string2 (equal) Compare string1 with string2. If string2 has the form /string/, then it is compared as a regular expression. See Regular expression notation for HTTP Server for more information.

string1 != string2 (not equal)
string1 < string2 (less than)
string1 <= string2 (less than or equal to)
string1 > string2 (greater than)
string1 > = string2 (greater than or equal to)
( test_condition ) True if test_condition is true.

!test_condition True if test_condition is false.

Test_condition1 && test_condition2 True if both test_condition1 and test_condition2 are true.

Test_condition1 || test_condition2 True if either test_condition1 or test_condition2 are true.


Variable substitution
Values can be supplied in the following ways:

Test can be supplied within a quoted string. For example:

For compatibility with HTTP Server (original), text can be supplied without a quoted string. For example:

A literal dollar sign can be supplied in a string using a backslash. For example:

A variable reference can be supplied within a character sequence using braces. For example:

If REMOTE_HOST is equal to X and REQUEST_METHOD is equal to Y, then $ABC is equal to X_Y.

Note: For compatibility with HTTP Server (original), a variable name can also begin with an ampersand (&).
Server-side include commands for HTTP Server (original)
HTTP Server (original) SSI commands have the following format:




The quotes around value are optional. However, quotes are required for imbedding spaces.

The following describes the SSI commands.

cmntmsg
Specifies the message appended to the beginning of any text that follows a directive specification and comes before -->. For example:

errmsg
Specifies a message that is sent back to the client if an error occurs while parsing the document. The message is logged in the server's error log. The default value is [an error occurred while processing this directive]. For example:

sizefmt
Specifies the format used to display the size of a file where bytes displays the file size in bytes or abbrev displays the file size in Kb or Mb. The default is abbrev. For example:

timefmt
Specifies the format used to display dates and time. See Time formats for HTTP Server. The default is %a, %d %b-%Y %T %Z. For example:

The following describes the SSI commands for HTTP Server (original).

echo
This command prints one of the SSI or API variables. Dates are printed using config timefmt. The attributes are:

var
Specifies an environment variable name or CGI environment variable name. See Environment variables on HTTP Server for a list of environment variables. For example:

exec
This command includes the output of a CGI program. The exec command discards any HTTP headers CGI outputs except for the following:

content-type
content-encoding
last-modified
cgi
Specifies the relative path and file name. For example:



fsize
This command prints the size of the specified file according to config sizefmt. The attributes are:

file
Specifies the relative path and file name. The file is assumed to be relative to the value contained in the SSI_ROOT environment variable if preceded by a /. If not preceded by a /, the file is assumed to be relative to the value of the SSI_DIR environment variable. For example:

virtual
Specifies the relative path and file name using URL encoding. The virtual attribute is always passed through the mapping directives. For example:

flastmod
This command prints the last modification time and date of the specified file according to config timefmt. The attributes are:

file
Specifies the relative path and file name. The file is assumed to be relative to the value contained in the SSI_ROOT environment variable if preceded by a /. If not preceded by a /, the file is assumed to be relative to the value of the SSI_DIR environment variable. For example:

virtual
Specifies the relative path and file name using URL encoding. The virtual attribute is always passed through the mapping directives. For example:

global
This command sets the value of an environment variable that can be echoed by this file or any included files. The attributes are:

var
Specifies an environment variable name.
See Environment variables on HTTP Server for a list of environment variables.

value
Specifies the value to assign to the environment variable name.
For example, if you want to refer to a parent document across the virtual boundary, you need to set a global variable DOCUMENT_URI. You must also refer to the global variable in the child document. The following is an example of the coding you need to insert in the parent document:


The following is an example of the coding you need to insert into the child document:


include
This command inserts the text of another file. Included files can be nested. The attributes are:

file
Specifies the relative path and file name. The file is assumed to be relative to the value contained in the SSI_ROOT environment variable if preceded by a /. If not preceded by a /, the file is assumed to be relative to the value of the SSI_DIR environment variable. For example:

virtual
Specifies the relative path and file name using URL encoding. The virtual attribute is always passed through the mapping directives. For example:



set
This command sets the value of an environment variable that only this file can echo later. Nothing is displayed if an unrecognized variable is found. The attributes are:

var
Specifies an environment variable name.
See Environment variables on HTTP Server for a list of environment variables.

value
Specifies the value to assign to the environment variable name. For example:

If you want to insert a special character in a string, precede it with a \. For example:


Additional notes
Server-side includes look for the variable, echoes where the variable is found, and proceeds with the function. You can have multiple variable references. When server-side includes encounter a variable reference inside a server-side include directive, it attempts to resolve it on the server side. The following example escapes the & so that server-side includes do not recognize it as a variable. In the second line of the example, the variable "&index" is a server-side variable and is used to construct the variable name "var1". The variable ê is a client side variable, so the & is escaped to create the value ":frêd" or "fred" with a circumflex over the e.




The following characters can be escaped. Escape variables must be preceded with a backslash (\).

Escape variable Meaning
\a Alert (bell)

\b Backslash

\f Form feed (new page)

\n New line

\r Carriage return

\t Vertical tab

\v Vertical tab

\' Single quote mark

\'' Double quote mark

\? Question mark

\\ Backslash

\- Hyphen

\. Period

\& Ampersand

No comments:

Post a Comment

Post a Comment