Server Side Include Commands

These commands should be written in a .shtml file that is indexed as a FileResource associated with a SSIFrame.

config

Used to set the sizefmt and datefmt variables, which control the output of file sizes and dates.

Parameters:

  • datefmt = the date format
  • sizefmt = the size format
Example:

<!--#config sizefmt="bytes" -->

cookie

Cookies access from server side includes.

Parameters:

  • get = name of the cookie to get
  • alt = alternative value
  • if = name of the cookie (just to test if the cookie exists)
  • then = value
Examples:

<!--#cookie get="C1" alt="hello" -->,
display the value of the cookie "C1" or "hello" if the cookie is not in the incomming request.

<!--#cookie if="C1" then="hello" alt="bye"-->,
Display "hello" if the cookie "C1" is in the request. If not display "bye".

count

This command inserts the number of recorded accesses to this resource, as reported by CounterFilter.

Parameters: none

Example:

<!--#hitcount -->

echo

As extensions, it has the parameters "reqstate" (for echoing Jigsaw request states) and "reqheader" (for echoing request header).Also, it can take the flag "here", whose presence means that the variable is to be interpreted at the deepest request level (in the case of chained internal requests), instead of doing so at the top (external request) level. It inserts the value of a variable in the document.

Parameters:

  • var = a SSI variable
  • reqstate = a Jigsaw request state
  • reqheader = a request header
  • here = a flag
Examples:

<!--#echo var="DOCUMENT_URI" -->
Display the document uri.

<!--#echo reqheader="referer" -->
Display the referer header of the request.

<!--#echo reqstate="pathinfo" -->
Display the request state "pahtinfo".

exec

It inserts the output from a CGI script or a shell command in the document. Note that in the Jigsaw architecture CGI scripts are just another resource class, so that no distinction is made between executing a CGI script or including a file.

Parameters:

  • cmd = the command to execute
Examples

<!--#exec cmd="ls -lsa" -->
Display the result of the ls command.

fLastmod

The standard lastmod SSI command.

Parameters: none

Example:

<!--#flastmod-->

fsize

It inserts the size of the unparsed file in the document, according to the current value of the variable sizefmt. See config command.

Parameters: none

Example:

<!--#fsize -->

include

CGI scripts can be included, simply by providing a so-called virtual path to a resource with a CgiFrame.

Parameters:

  • file = the file to include
  • virtual = a virtual path
  • ifheader = a request header
  • else = a file
Examples:

<!--#include file="included.html" -->
Include the file "included.html" in the current file.

<!--#include ifheader="Referer" file="included.html" else="included2.html" -->
If the request has a Referer header then include "included.html" else include "included2.html".

jdbc

Allows you to query a SQL database via JDBC. Combinated with some Control Commands, it allows you to display the content of a database easyly.

Parameters:

  • select = the SQL request
  • url = the database URL
  • driver = the JDBC driver class
  • user = the username
  • password = the password
  • name = the result name
  • column = the column number
  • next = a flag
Examples:

<!--#jdbc select="SELECT * FROM services" name="result" driver="com.imaginary.sql.msql.MsqlDriver" url="jdbc:msql://www43.inria.fr:4333/services" -->
This is the setup of the command.

<!--#jdbc name="result" next="true" -->
This command move the pointer to the next line of the result set.

<!--#jdbc name="result" column="1" -->
Display the first column of the current line.

<!--#jdbc name="result" column="2" -->
Display the second column of the current line.

<!--#jdbc name="result" column="3" -->
Display the third column of the current line.

servlet

Servlet can be executed simply by providing a url path to a servlet class.

Parameters:

  • name = the command identifier
  • code = the servlet URL
  • param = a parameter name
  • value = a parameter value
Examples:

<!--#servlet name="Snoop" param="p1" value="v1" -->

<!--#servlet name="Snoop" param="p2" value="v2" -->

<!--#servlet name="Snoop" param="p3" value="v3" -->

<!--#servlet name="Snoop" code="/servlet/snoop" -->

counter

Used to do things like cpt = cpt + 1

Parameters:

  • name = the counter identifier
  • init = the init value
  • incr = the value to add to the counter
  • value = a flag
Examples:

<!--#cpt name="cpt1" init="0" -->
Initialisation: cpt1 = 0

<!--#cpt name="cpt1" incr="1" -->
cpt1 = cpt1 + 1

<!--#cpt name="cpt1" value="true" -->
Display the current value of cpt1.

else

Parameters:

  • name = the if command identifier
Example:

<!--#else name="if2" -->

endif

Parameters:

  • name = the if command identifier
Example:

<!--#endif name="if2" -->

endloop

Parameters:

  • name = the loop command identifier
Example:

<!--#endloop name="loop2" -->

exitloop

Parameters:

  • name = the loop command identifier
  • command = a command name (jdbs, cpt)
  • var = a command identifier
  • equals = a string value
Example:

<!--#exitloop name="loop2" command="cpt" var="cpt1" equals="4" -->

if

Parameters:

  • name = the command identifier
  • command = a command name (jdbc, cpt)
  • var = a command identifier
  • equals = a string value
Example:

<!--#if name="if2" command="cpt" var="cpt1" equals="2" -->

loop

Parameters:

  • name = the command identifier
Example:

<!--#loop name="loop2" -->

Copyright © 1999 by W3C (MIT, INRIA, Keio ).

Last update: 2019-05-24T17:05:14+00:00