CSDN博客

img wensilan

SSI 参考 - 2。

发表于2004/7/12 0:10:00  849人阅读

EchoCommand

The echo SSI command. 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" 

ExecCommand

the SSI exec command. 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
Example:
<!--#exec cmd="ls -lsa" --> display the result of the ls command 

FLastModCommand

The standard lastmod SSI command.
Parameters: none
Example:
<!--#flastmod--> 

FSizeCommand

The SSI fsize command. It inserts the size of the unparsed file in the document, according to the current value of the variable sizefmt.See configCommand.
Parameters: none
Example:
<!--#fsize --> 

IncludeCommand

The SSI include command. (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" 

jdbcCommand

The SSI jdbc command 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
Example:
<!--#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. 

ServletCommand

The SSI servlet command. 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
Example:
 <!--#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" --> 

Control Commands

CounterCommand

The SSI counter command. 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
Example:
<!--#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 

ElseCommand

Parameters:
  • name = the if command identifier
Example:
<!--#else name="if2" --> 

EndifCommand

Parameters:
  • name = the if command identifier
Example:
<!--#endif name="if2" --> 

EndloopCommand

Parameters:
  • name = the loop command identifier
Example:
<!--#endloop name="loop2" --> 

ExitloopCommand

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" --> 

IfCommand

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" --> 

LoopCommand

Parameters:
  • name = the command identifier
Example:
<!--#loop name="loop2" --> 

Example

The following example, display the four first columns of the three first lines of the users database.
 <!--#jdbc name="result2" select="SELECT * FROM users" user="bmahe" password="" url="jdbc:msql://www43.inria.fr:4333/users" driver="com.imaginary.sql.msql.MsqlDriver" --> <table border=2> <!--#cpt name="cpt1" init="0" --> <tr><td><b>Name </td><td><b>Login</td> <td><b>Email</td><td><b>Age </td></tr> <!--#loop name="loop2" --> <!--#jdbc name="result2" next="true" --> <tr> <td> <!--#jdbc name="result2" column="1" --> </td><td> <!--#jdbc name="result2" column="2" --> </td><td> <!--#jdbc name="result2" column="3" --> </td><td> <!--#jdbc name="result2" column="4" --> </td> </tr> <!--#cpt name="cpt1" incr="1" --> <!--#exitloop name="loop2" command="cpt" var="cpt1" equals="3" --> <!--#endloop name="loop2" --> </table> counter value : <!--#cpt name="cpt1" value="true" --> 

The result could be:

Name Login Email Age
Smith ssmith ssmith@example.org 25
lafrim ylafrim lafrim@example.org 25
Teole pteole teole@example.org 27
0 0

相关博文

我的热门文章

img
取 消
img