|
To access the contents, click the chapter and section titles.
HTML 4.0 Sourcebook
This powerful feature should not be overused, however, as every parsable file must be specially processed by the server, which can significantly slow server response. As a result, most servers come with this feature initially disabledyou have to explicitly turn it on. Each servers documentation explains how this is done, if it is supported. Server-side includes are well documented in the NCSA HTTPD server on-line manuals, referenced at the end of this chapter. Also referenced are several sites on the Web that provide useful interactive tutorials illustrating server-side includes. Include Command FormatThe server-side include mechanism is framed inside an HTML comment string: <!--#include_command --> When parsed by a server supporting this feature, the entire comment string is replaced by the output of include_command. Because the command is inside a comment string, this will not cause problems if the document is processed by a server that does not support this feature or that has this feature disabled. Such servers will simply deliver the document, including the comment line, and the client will treat the string as a comment and ignore it. The general form for the include command is: <!--#command arg1=value1 arg2=value2 --> where command is the name of the command to be executed and arg1 and arg2 are arguments passed to the command. There must be no space between the hash sign (#) and the command name, or between the hash sign and the leading double dash (--#). The number and name of the argument(s) depend on the actual command; most commands take a single argument. Note that, despite its structure, this is not a comment statement. You cannot include comment descriptions inside an include command. Consequently, lines like <!--#command arg1=value1 This prints the time of day --> are invalid. There are six SSI commands: config, include, echo, fsize, flastmod, and exec. Config configures the way the server parses the document. Include includes another document (not a CGI program) at the indicated location, while echo includes the contents of one of the special environment variables that are set for parsed documents. Fsize and flastmod are similar to echo; fsize prints the size of a specified file, while flastmod prints the last modification date of a specified file. Finally, exec executes a single-line Bourne-shell command, or a CGI program. For security reasons, the exec facility can be disabled in the server configuration files, while leaving the other features operational. The next sections describe each of these commands, and how they work; entries in italics are variables to be set by the document author. Table 11.1 summarizes the commands and the allowed forms. IncludeInclude Another Document This directive includes another document (or another parsed document) at the given location in the current documentit cannot include CGI program output. Include takes two arguments to specify the file to be included. These are: virtual=virtual-path/file
EchoInclude Value of a Variable This includes the contents of a named environment variable. The variable is indicated by the argument var="var_name, where var_name can be any of the CGI environment variables listed in Tables 10.2 and 10.3 (except QUERY_STRING and PATH_INFOsee the discussion of the exec include mechanism later in this section) or one of the special environment variables listed in Table 11.2, valid only in parsable files or in CGI programs called from a parsable file. FsizeInclude Size of Listed File This includes the size, in bytes, of a filethe file can be specified using either the file or virtual arguments, as described in the include command section.
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |