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.
NOTE: As of 2.0beta2, Jisgaw is compatible with the JSDK2.0 including session tracking (using cookies or URL rewriting).
IMPORTANT: Before setting up servlets in Jigsaw, you must get the Servlet Development Kit available at Javasoft and update your CLASSPATH to use those classes (add jsdk.jar in your CLASSPATH).
By default you just have to put the servlet class file in the <instdir>/Jigsaw/Jigsaw/WWW/servlets/ directory that is already configured for servlets. For example, if you put SessionServlet.class in <instdir>/Jigsaw/Jigsaw/WWW/servlets/, this servlet will be reachable at http://your-server-host/servlets/SessionServlet.
But if you want to configure your servlets manually, please read the following paragraph:
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 org.w3c.jigsaw.resources.DirectoryResource with a org.w3c.jigsaw.servlet.ServletDirectoryFrame frame to export it (if the directory has already been indexed, you have to remove the existing org.w3c.jigsaw.frames.HTTPFrame). 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:
Now DateServlet is reachable at http://your-server-host/servlets/DateServlet.
Now you can setup a special indexer for servlets:
org.w3c.jigsaw.servlet.ServletIndexer. This indexer perfoms
some servlet specific actions before indexing the class file in a ServletWrapper.
It verify that the class file is really a servlet class file, then it put
the filename (without the "class" extension) as the identifier and the entire
filename as the servlet class. So a class file that is not a servlet class
file will NOT be indexed by this indexer but it could be indexed (in a
FileResource for example) by one of its super indexer.
See the Indexer Configuration documentation for
more details on indexers.
Just add a ServletWrapper called "class" in the extensions node of your ServletIndexer, modify the field you want in the ServletDirectoryFrame (ie: Title, Icon), commit and save your modifications. Now you just have to set your indexer as the indexer of your servlet directory and your servlets will automaticaly be indexed.
In the last version of Jigsaw, you have many properties to configure.
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.
In the two first versions of Jigsaw2.0 (beta1 and beta2) this feature can be disabled because in some case the auto-reload feature could create some problems. In those versions there is a auto-reload flag in ServletWrapper.
Now this problem has been resolved and we don't need the auto-reload flag anymore. But the auto-reload feature works only for the servlet classes located in the servlet directory. Servlets in the CLASSPATH are loaded by the system ClassLoader and their modified classes are not reloaded while the server is running.
Note: For very good reasons, when a servlet class is reloaded all sessions are invalidated.
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.
Note : the url http://www.servlet.com/RemoteServlet.class must be a Java compliant class file.
NOTE: The default version of Jigsaw has been compiled with servlet support, to use it dowload the JSDK available at Javasoft and update your CLASSPATH to use those classes.
Be sure to have a recent version of the servlet 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.
Jigsaw Team
$Id: servlets.html,v 1.40 1998/10/01 08:50:54 ylafon Exp $