Procedure to install jserv and JSP support for Apache under Linux

Environment: Mandrake Linux 7.0, apache 1.3.12 with mod_so and php3_module
Installation includes: JDK 1.2.2, JDSK 1.2.2, ApacheJServ 1.1.2, GNUJSP

MAKE SURE that apxs is available, from apache-devel RPM.

  1. Install JDK 1.2
    Get JDK from ftp://ftp.tux.org/pub/java/JDK-1.2.2/i386/FCS/j2sdk-1.2.2-FCS-linux-i386-glibc-2.1.3.tar.bz2 and install by executing
    
    cd /usr/local; bzcat  | tar xvf -
    
    
    verify that /usr/local/jdk1.2.2/bin/jar works correctly (if it doesn't, the glib libraries are probably not installed or out of date)
  2. Install JSDK2.0
    Get JSDK2.0 from http://java.sun.com/products/servlet/download.html and install by
    
    cd /usr/local; tar xzvf 
    
    
  3. Install Jikes
    Jikes is a better java compilier from IBM. Get it from http://www10.software.ibm.com/developerworks/opensource/jikes/project/stable/jikes-1.06-1.i386.rpm and install by
    
    rpm -Uvh jikes-1.06-1.i386.rpm
    
    
  4. Install Jserv
    Get JServ from http://java.apache.org/jserv/dist/ApacheJServ-1.1.2.tar.gz and install by executing
    
    cd /usr/local; tar xzvf 
    cd /usr/local/Apache
    
    ./configure
    
    

    lots of lines of output, hopefully ending something like:
    
    Apache include flags:
      -I/usr/include/apache
    
    Default configuration files will be installed in:
      /etc/httpd/conf/jserv
    
    Default log files will be created in:
      /usr/logs
    
    Default servlets will be installed in:
      /usr/servlets
    
    ApacheJServ.jar file will be installed in:
      /usr/lib/apache/ApacheJServ.jar
    
    Documentation will be installed in:
      /usr/local/jserv/docs
    
    Build classpath is:
      /usr/local/ApacheJServ-1.1.2/src/java:/usr/local/jdk1.2.2/jre/lib/rt.jar:/usr/
    local/JSDK2.0/lib/jsdk.jar
    
    You might consider putting frequently used options into
    ./configure-options, one per line.
    
    +-STEP 1-------------------------------------------------------+
    |Run 'make; make install' to make a .jar file, compile the C   |
    |code and copy the appropriate files to the appropriate        |
    |locations.                                                    |
    +--------------------------------------------------------------+
    
    +-STEP 2-------------------------------------------------------+
    |Put this line somewhere in Apache's httpd.conf file:          |
    |Include /etc/httpd/conf/jserv/jserv.conf
    |                                                              |
    |Then start Apache and try visiting the URL:                   |
    |http://tower:SERVER_PORT/servlets/Hello
    |                                                              |
    |If that works then you have successfully setup Apache JServ.  |
    |                                                              |
    |If that does not work then you should read the                |
    |troubleshooting notes referenced below.                       |
    +--------------------------------------------------------------+
    
    +-Troubleshooting----------------------------------------------+
    |Html documentation is available in the docs directory.        |
    |                                                              |
    |Common Errors:                                                |
    |    Make sure that the log files can be written to by the     |
    |    user your httpd is running as (ie: nobody). If there are  |
    |    errors in your configuration, they will be logged there.  |
    |                                                              |
    |Frequently asked questions are answered in the FAQ-O-Matic:   |
    |                                                              |
    |           http://java.apache.org/faq/                        |
    +--------------------------------------------------------------+
    
    

    Now make and install the package by:
    
    make; make install
    
    

    add "Include /etc/httpd/conf/jserv/jserv.conf" to the end of the /etc/httpd/conf/httpd.conf file, restart Apache by apachectl restart
  5. Test operation of JServ
    use a web browser to go to http:///servlets/Hello

    A page should come up saying

    
    Example Apache JServ Servlet
    Congratulations, ApacheJServ 1.1.2 is working!
    
    

    from the same machine, you can open a browser to display the status of JServ at http://localhost/jserv

    If you want to check it from other systems, you must modify the permissions in the /etc/httpd/conf/jserv/jserv.conf file.

  6. Install GnuJSP
    get from http://www.klomp.org/gnujsp/downloads/gnujsp-1.0.0.tar.gz and install by
    
    cd /usr/local; tar xzvf gnujsp-1.0.0.tar.gz
    cp /etc/httpd/conf/jserv/zone.properties /etc/httpd/conf/jserv/alph.properties
    
    
    In the alph.properties file, change the list of repositories to:
    
    repositories=/usr/local/gnujsp-1.0.0/lib/gnujsp10.jar
    repositories=/usr/local/gnujsp-1.0.0/lib/servlet-2.0-plus.jar
    
    
    and add these to the Servlet Aliases section:
    
    servlet.gnujsp.code=org.gjt.jsp.JspServlet
    servlet.gnujsp.initArgs=checkclass=true,pagebase=/home/httpd/html/,
    	scratchdir=/var/local/apache/jsp,debug=true,compiler=builtin-javac
    	-classpath %classpath%:%scratchdir%:
    	/usr/local/gnujsp-1.0.0/lib/servlet-2.0-plus.jar:
    	/usr/local/gnujsp-1.0.0/lib/gnujsp10.jar -d %scratchdir%
    	-deprecation %source%
    
    
    If using jikes, the initArgs line should read:
    
    servlet.gnujsp.initArgs=checkclass=true,pagebase=/home/httpd/html/,
    	scratchdir=/var/local/apache/jsp,debug=true,compiler=/usr/bin/jikes
    	-classpath %classpath%:%scratchdir%:
    	/usr/local/gnujsp-1.0.0/lib/servlet-2.0-plus.jar:
    	/usr/local/gnujsp-1.0.0/lib/gnujsp10.jar:/usr/local/jdk1.2.2/jre/lib/rt.jar
    	-d %scratchdir% -deprecation %source%
    
    
    If it isn't obvious, the servlet.gnujsp.initArgs lines are a single line, not multiple lines as above shown for clarity! Change the "zones=root" line in the jserv.properties file to include the newly create "alph" zone, e.g. zones=root,alph
    and add a line to point to the properties file such as alph.properties=/etc/httpd/conf/jserv/alph.properties

    add to the /etc/httpd/conf/jserv/jserv.conf file:

    
    ApJServAction .jsp /alph/gnujsp     
    ApJServMount /alph /alph
    
    
    Make sure that the log files and scratch directory selected exist. Also verify that all .jar files are where you said they are. Restart Apache by apachectl restart
  7. Test operation of GnuJSP
    Copy the example files from the gnujsp/examples directory to a directory such as "myexamples" under your apache document root.

    in a browser, try bringing up a file such as http://yourhost/myexamples/hello.jsp

    You should get the Congratulations message. If you don't, go back and check the paths, syntax errors, etc.
    Unfortunately, the error logs are going to be fairly cryptic if you have a problem. Look at the jserv.log and mod_jserv.log files and you may get sufficient hints to correct any issues.