w3c 

Servlets and Jigsaw


What are servlets ?

Servlets are server-side extensions programmed against the Servlet API. This interface is philosophically equivalent to the old CGI interface, but is both more powerful and extremely more efficient. More information is available at jeeves.javasoft.com.


How do I compile Jigsaw to use the servlets ?

NOTE: The default version of jigsaw has been compiled with servlet support, to use

Be sure to have a recent version of the servlet classes. Update your CLASSPATH to use those classes. Modify the Makefile in src/classes/org/w3c/jigsaw and add the servlet package at the end of the PACKAGES list, like this:
 

tutorials \
zip \
servlet
Then, uncomment the line 146 of org/w3c/jigsaw/ssi/commands/DefaultCommandRegistry.java like this:
 
new org.w3c.jigsaw.ssi.servlets.ServletCommand()
and adds the servlets package in the Makefile of the org.w3c.jigsaw.ssi package, like this:
 
PACKAGES = \
commands\
jdbc \
servlets
Now, you can recompile jigsaw.


How do I install a servlet ?

Installing a servlet is pretty easy !

First of all, you have to choose where you want to place your servlets in your file system; this will usually be a single directory, typically something like servlets under your server's WWW directory. Once you have created the file system directory, create a Jigsaw org.w3c.jigsaw.resources.DirectoryResource with a org.w3c.jigsaw.servlet.ServletDirectoryFrame frame to export it. That frame will act as a context for all the servlets under it (Jigsaw can handle multiple servlet contexts within a single server). You can now add servlets into this special directory. Each servlet is managed by a org.w3c.jigsaw.servlet.ServletWrapper, to add a servlet you just have to create a ServletWrapper and in the servlet-class field put the class name of the servlet witch must be in the directory relative to the DirectoryResource or in the CLASSPATH.

Example :

You want to install the DateServlet in the WWW/servlets directory:

  1. Create the directory servlets under WWW
  2. Start the JigAdmin program and unfold all the nodes down to the space node.
  3. Select the space node, and activate the Resources editor helper. Enter the DirectoryResource identifier (ie servlets) and the class of the resource (ie org.w3c.jigsaw.resources.DirectoryResource). This should be done automatically by the indexer.
  4. Add a org.w3c.jigsaw.servlet.ServletDirectoryFrame to your new DirectoryResource (and eventually remove the old HTTPFrame).
  5. Put the servlet class (ie DateServlet.class) in WWW/servlets (or in the CLASSPATH).
  6. Create a ServletWrapper in the DirectoryResource and call it DateServlet for example. 
  7. Set the servlet-class field of the ServletWrapper to DateServlet 
  8. Commit your changes
Now DateServlet is reachable at http://your-server-host/servlets/DateServlet.


Is Jigsaw compatible with the JSDK2.0?

Yes, Jigsaw2.0 is compatible with the last JSDK, including HttpSession (Using Cookies).


How can I setup the servlets properties?

In the last version of Jigsaw, you have many properties to configure.
  1. Servlet log file : You can specify the log file to use for servlets. The default log file is <instdir>/Jigsaw/Jigsaw/logs/servlets.
  2. Sessions max idle time : Amount of time a session is allowed to go unused before it is invalidated. Value is specified in milliseconds.
  3. Max sessions : Max number of sessions in memory, if the number of sessions exceeds this number the sessions with the bigest idle time will be invalidated. This is checked each time a session is added.
  4. Sessions check delay : Time interval when Jigsaw checks for sessions that have gone unused long enough to be invalidated. Value is an integer, specifying the interval in milliseconds.
  5. Session cookie name : The name of the cookie carrying the session ID.
  6. Session cookie path : The path of the cookie carrying the session ID. (optionnal)
  7. Session cookie domain : The domain field of the cookie carrying the session ID. (optionnal)
  8. Session cookie comment : The comment field of the cookie carrying the session ID. (optionnal)
  9. Session cookie maxage : The value of the maximum age of the cookie carrying the session ID. Default value is 86400 seconds (24h).
  10. Session cookie secure : The secure field of the cookie carrying the session ID.

How does Jigsaw load local servlet classes ?

Jigsaw use a local ClassLoader to load servlet classes from the servlets Directory. If a servlet class is modified when Jigsaw is running, the ClassLoader load automatically the new class. It's a very useful feature for servlets developers

This feature can be disabled because in some case the "auto-reload" could create some problems. There is a "auto-reload" flag in ServletWrapper.


How can I load remote servlets ?

You can use remote servlets by using a RemoteServletWrapper instead of the ServletWrapper.

Example : Add the remote servlet http://www.servlet.com/RemoteServlet.class to jigsaw.

  1. Create the RemoteServletWrapper in the ServletDirectory.
  2. Set its "servlet-base" field to http://www.servlet.com/
  3. Set its "servlet-class" field to "RemoteServlet" (without .class)
  4. Commit changes.
Note : the url  http://www.servlet.com/RemoteServlet.class must be a Java compliant class file.


Jigsaw Team
$Id: servlets.html,v 1.15 1998/07/02 09:22:36 benoit Exp $