A step-by-step tutorial on setting up JServ

  1. First you need to download Apache JServ. It is freely available from http://java.apache.org. The Version used in this tutorial is 1.1.

  2. Make sure you have a Java Runtime Environment. i.e. that you can run Java programs on your machine! JREs for many platforms are freely available from: http://java.sun.com/cgi-bin/java-ports.cgi

  3. Make sure you have a copy of Sun's Java Servlet Development Kit v2.0, freely available from: http://java.sun.com/products/servlet/index.html. The version of JServ used in this tutorial needed exactly the 2.0 version.

  4. The only files you need from Apache JServ distribution are:
        ApacheJServ-1.1/src/java/ApacheJServ.jar
        ApacheJServ-1.1/conf/jserv.properties.in
        ApacheJServ-1.1/conf/zone.properties.in
    
    We are going to install JServ in /usr/local/jserv in this example:
        $ mkdir /usr/local/jserv
        $ cd ApacheJServ-1.0
        $ cp src/java/ApacheJServ.jar /usr/local/jserv
        $ mkdir /usr/local/jserv/conf
        $ cp conf/jserv.properties.in    /usr/local/jserv/conf/jserv.properties
        $ cp conf/zone.properties.in     /usr/local/jserv/conf/zone.properties
    

  5. Now we need to edit the config files we have put in /usr/local/jserv/conf.

    First, edit jserv.properties. This file contains various global settings for the JServ servlet runner. You may need to alter the settings in here to suit your environment.

    E.g. in this example, the only alterations we made were:

    alter
        root.properties=...
    to
        root.properties=/usr/local/jserv/conf/zone.properties

    and
        log.file=...
    to
        log.file=/tmp/jserv.log

    Now edit zone.properties. This zone file defines settings for all the servlets in a particular zone, such as where the servlets should be found on disk. JServ can be setup to run with multiple zones, generally you have one per virtual server. In this example, we only have one zone defined in the jserv.properties file called "root", and we have set the "root.properties" value to point to the zone.properties file we are now editing. For more information on zones, check out the JServ documentation on the JServ website.

    In our example, all we are going to do to the zone.properties file is alter the repositories line to define where our servlets will live on disk. (/usr/local/jserv/servlets in our case).

    So we set
        repositories=/usr/local/jserv/servlets

  6. We are now ready to start up the JServ servlet runner. The servlet runner is started independently of Zeus Server. JServ need not be run on the same machine as the webserver, as Zeus can communicate with JServ over the network. In our example, we have the Java Runtime Environment installed in /usr/java, so the Java interpreter is accessed as /usr/java/bin/java. We have also copied the "jsdk.jar" file from Sun's Java Servlet Development kit you downloaded in step 2, to /usr/local/jserv/jsdk.jar.
      $ cd /usr/local/jserv
      $ CLASSPATH=jsdk.jar:ApacheJServ.jar /usr/java/bin/java org.apache.jserv.JServ conf/jserv.properties
    
    JServ should now startup, and print out a version number.
      ApacheJServ/1.0
    
    To run the program in the background, you should append a "&" on the end of the command above.

  7. Now JServ is setup and running, we can now configure Zeus Webserver to communicate with it.

    Go to the Zeus Admin Server, and choose a virtual server to add Jserv support to. On the module configuration page for the webserver, click on the "JServ" red-cross to get a green-tick to enable to JServ module. Then click on the word "JServ" to get to the JServ configuration page.

    The defaults are setup to work straight away with the out-of-the-box JServ configuration, so simply click on "Add" to add this mount point. And URL beginning with a prefix of "/jserv" will now cause the webserver to forward to request onto the JServ server.

    Go back to the traffic-light page and restart that virtual server so our new configuration modifications take effect.

  8. Now we are ready to access servlets from our webserver.

    First, try to access the internal status servlet in JServ. For example, if your website runs on http://www.mysite.com, access the URL http://www.mysite.com/jserv/org.apache.jserv.JServ.

    This should bring up a webpage showing the current status of the servlet engine and servlet zones defined. (This servlet can be disabled in the jserv.properties file!)

    Now lets try running one of our own servlets.

    From the JSDK distribution you downloaded in step 2, copy the SnoopServlet.class file from the examples/ directory into /usr/local/jserv/servlets.

    Now access /jserv/SnoopServlet, e.g. http://www.mysite.com/jserv/SnoopServlet.

    This should run Sun's example servlet and display various information about the servlet environment in your browser.

  9. You are now ready to write your own servlets! Its highly recommended that you read through the JServ documentation as there are a lot of powerful and configurable features you may wish to use.