- Any servlet engine compatible with the 2.0 Servlet API specification (the use of Apache JServ is highly recommended). Note that the JSDK 2.1 isn't supported yet and the SSI servlet may or may not work with JSDK 2.1 compliant servlet engines.
- Any Java 1.1 compatible compiler
You need to have the Java Servlet API (JSDK) 2.0 in your CLASSPATH to compile Apache JSSI. Please get this from: http://java.sun.com/products/servlet/
To compile the source code, go to the src/java directory and type:
$ makeyou'll get ApacheJSSI.jarIf you grabbed the distribution, the ApacheJSSI.jar is already compiled for you.
In order to include the Apache JSSI classes in your servlet engine, you have to enable the server side inclusion by mapping the ".jhtml" URI to the "org.apache.servlet.ssi.SSI" servlet by doing the following:
In your Apache config file add:
ApJServAction .jhtml /servlets/org.apache.servlet.ssi.SSIChange the /servlets/ part to be the location of your zone. In your zone.properties file add the ApacheJSSI.jar to your repository:repositories=/path/to/ApacheJSSI.jarChange the /path/to/ part to be the path to the location of your ApacheJSSI.jar file.If you would like to use the URL-Rewriting feature, use the org.apache.servlet.ssi.ParameterPropagatingSSI - Servlet instead. Consult the documentation for further information.
Apache JSSI will work with other servlet engines that meet the requirements defined above. Please see the Apache JServ installation instructions for hints on how to configure your servlet engine in order to do suffix/action mapping.
The SSI Servlet understands some optional parameters which can be given in the init Arguments:
With Apache JServ, you just have to insert a line in your zone.properties file go apply these parameters:
SSISiteRoot
(path)
In order to use traditional SSI directives (<!--#..), pass the following init argument to the "org.apache.servlet.ssi.SSI" servlet (by following your servlet engine instructions):SSISiteRoot=/site/rootReplace /site/root by the top level directory of your site. This is theDocumentRoot
in your Apache configuration file.Beware, the SSI directives are not (yet) fully implemented. See documentation.
expires
(integer)
SSI documents usually contain dynamic content and thus shouldn't be cached by clients. With theexpires
parameter you can give the number of seconds after the generated document should be considered stale. Use negative values to prevent caching (expiration in the past).
This sets theExpires
header ( RFC2068, 14.21).
compresslarge
(size in Bytes)
experimental. If the output becomes larger than the given number of bytes, it is compressed. The size of the output which decides whether deflation is used or not is a heuristic value based on the size of the last generated pagesizes. It is a weighted mean value: 1/2*(size of lastpage) + 1/4*(size of the page before) + 1/8*... First call of the page will not be compressed.Output is only compressed if the browser supplies the
Accept-Encoding
Header. Supported compress algorithms are gzip and compress. Note that compression uses CPU cycles and takes a bit of time. So using this option may not make much sense for the intranet but may be useful for pages larger than several 10s kB served to the internet (I'd love it if this would be done on slashdot ..) See the output of your access_log for result: typical pages become 5-10 times smaller with compression.MS Internet Explorer seems to be buggy regarding this: it claims in the Accept-Encoding header to accept gzip'ed content but displays garbage, so compression is turned off if the String MSIE is found in the User-Agent header. If you find other browsers which are buggy or a solution to this problem please write to the Java Apache Mailing List with [jservssi] included in the Subject.
This evaluates the
Accept-Encoding
header and sets theContent-Encoding
andVary
headers ( RFC2068, 14.3, 14.12, 14.43).
buffered
("yes"|"no")
- default no -
Buffer the Output of the SSI servlet. This is needed if you want to set headers within in the included servlets which should affect the whole output. Use this if you need to set headers (i.e. cookies, esp. if you want to use cookie based session handling; see documentation of your servlet engine). Another feature is, that output is a bit faster than without buffering if you have many 'active' places in the Page, e.g. doing URL rewriting with the ParameterPropagatingSSI.Drawbacks are, that this uses a bit more memory (the whole page output is buffered) which in turn is work for the garbage collector. And you've to wait until the whole page is created which may make you feel that it's indeed slower ..
Since the buffered output allows to determine the pagesize, this options sets the
Content-Length
header ( RFC2068, 14.14).
debug
("yes"|"no")
- default no -
Logs how long it took to process the page to the servlet log. Useful if you want to experiment with thecompresslarge
andbuffered
options to see how it effects processing.
charset
(String containing the charset)
- default none -
Set the charset.This option modifies the
Content-Type
Header. Usually, this is set to"text/html"
, with the charset attribute its something like e.g."text/html; charset=koi8-r"
. ( RFC2068, 14.18).
PropagateParameters
(';'-seperated stringlist)
ParameterPropagatingSSI
only: semicolon seperated list of parameters to be propagated. See installation section of the document describing this servlet.
Example:servlet.org.apache.servlet.ssi.SSI.initArgs=SSISiteRoot=/site/root,expires=-1000
Servlet output may be included in an HTML document by use of the
tag. For example, to embed the output of the HelloWorldServlet servlet in an HTML page, you might write the following: ... (some HTML code) ... <SERVLET CODE="HelloWorldServlet.class"> Your web server has not been configured to support servlet tags. </SERVLET> ... (more HTML code) ...When this page is served from the web server, the code above will be replaced with the output of HelloWorldServlet. If you see the message between the tags instead, there is a problem with your server configuration. If this happens, check to make sure your file has a ".jhtml" extension and that the server is properly configured.
Two attributes are used by the <SERVLET> tag, and they are roughly equivalent:
- The CODE attribute may be set to the name of a class file (the ".class" extension is optional) containing the servlet to be run. This servlet must be visible by the Apache JSSI servlet.
- The NAME attribute may also be set to the name of the servlet to be run (with no class extension).
In some implementations of <SERVLET> tags, if both NAME and CODE attributes are set, the servlet designated by CODE will then become available for future use under the symbolic named designated by the NAME attribute. This is not currently supported.
Note that both the <SERVLET> and </SERVLET> tags must be present.
You may send parameters to a servlet via the PARAM tag, which should be placed between the <SERVLET> and </SERVLET> tags, like so:
<SERVLET CODE="MyServlet.class"> <PARAM NAME="param1" VALUE="valueOfParam1"> <PARAM NAME="anotherParam" VALUE="valueOfAnotherParam"> </SERVLET>You could then access these parameters from your servlet as follows:
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { String param1 = req.getParameter("param1"); String anotherParam = req.getParameter("anotherParam"); }For use of the URL rewriting and traditional SSI features please follow the links.Copyright (c) 1997-99 The Java Apache Project.
All rights reserved.