|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
Common SSI CommandsYou can use SSI commands for a variety of tasks, including inserting (echoing) a value into the document, running a program, inserting the contents of a file into the document, setting the way file sizes appear, inserting the hit count or a file size into the document, and more. The following sections provide step-by-step examples of SSI commands in action.
echo The following is the syntax for echo: The current date is <!--#echo var=DATE_LOCAL --> This syntax expands to something like the following when executed by an NCSA or Apache server: The current date is 28 Feb 1999 12:00:13 GMT-6 The command is echo, the tagname is var (short for variable), and the parameter is DATE_LOCAL, which is a variable defined by the NCSA server that represents the local time on the server. When the server processes this line, it sees that the command requires it to echo (print) something. The echo command takes only one parameter, the keyword var, which is followed by a value specifying which variable you want to be echoed. Most servers let you echo at least a subset of the standard CGI variables, if not all of them. You can usually find some special variables that are available only to SSI. DATE_LOCAL is one of them. Again on the NCSA or Apache server, you can change the time format using the SSI config command, as follows: <!--#config timefmt=format string --> Substitute a valid time format string for format string in the preceding example. The syntax of the format string is compatible with the string you pass to the UNIX strftime() system call. For example, %a %d %b %y gives you Sun 28 Feb 99. Here are some other useful variables you can echo: You are calling from <!--#echo var=REMOTE_ADDR--> This outputs a line like You are calling from 38.247.88.150 Heres another example: This page is <!--#echo var=DOCUMENT_NAME--> This yields a line resembling This page is /home/joeblow/ssitest.shtml Spend some time learning which variables your server lets you echo and the syntax for each. Related commands, such as the config timefmt command, often affect the way a variable is printed. include The include command typically takes one of two attributes, file or virtual, with a single parameter specifying which file to include. Using the file attribute, the included file must be something relative to, but not above, the current directory. Thus, ../ is disallowed, as is any absolute path, even if the httpd server process would normally have access there. The virtual attribute allows you to include any file relative to the document root. For example, /otherdir/file.html can be included as long as the Web server can access the file. Other servers let you specify any path at all, or work with the operating system to limit access in a more flexible way than hard-coding forbidden paths. Purveyor, for instance, lets you use UNC file specifications, thus allowing your include to pull its data from anywhere reachable on the network. Regular Windows NT file permission requirements must be met, of course. Dont give the user ID under which Purveyor runs access to areas you dont want to include.
|
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. |