Running servlets under Linux

Much of the following information is taken from http://jakarta.apache.org/tomcat/tomcat-4.1-doc/RUNNING.txt
  1. Make sure your Apache server is running. (One easy way is to do a ps -augx | grep httpd, you should see a number of entries.) If it isn't, you can manually start Apache via apachectl start, but you'll have to be superuse to do so.
  2. Obtain Jakarta Tomcat, a servlet container for web servers (including Apache).  Jakarta.apache.org
  3. Current Tomcat release is 4.1.18, which supports JSP v1.2 and Servlet v2.3.
  4. Full documentation at http://jakarta.apache.org/tomcat/tomcat-4.1-doc/index.html
  5. You must obtain a recent JDK (v1.2 or better).   http://java.sun.com/j2se
  6. Download a binary distribution of Tomcat from: http://mirrors.midco.net/pub/apache.org/jakarta/tomcat-4/binaries/  (for a linux installation, you’ll want to download jakarta-tomcat-4.0-YYYYMMDD.tar.gz (where the “YYYYMMDD” corresponds to the date when the release was put there.)) If you want to save a step, download this file into /usr/local/

Installing J2SE (JDK) 

(Also, see http://www.halley.cc/ed/linux/howto/java.html.)
  1. Download JDK from javasoft.com.  You should obtain the RPM version for linux.
  2. The result will be a file  j2sdk-1_4_1_01-linux-i586-rpm.bin
  3. chmod  j2sdk-1_4_1_01-linux-i586-rpm.bin, to make that file executable.
  4. Switch to super-user mode.
  5. Move the file to be in /usr/local.  cd to that directory
  6. Do ./j2sdk-1_4_1_01-linux-i586-rpm.bin, to run the program.
  7. You will be asked a licensing question.  If you answer yes, java will be unpacked, yielding the file, j2sdk-1_4_1_01-fcs-linux-i586.rpm.
  8. To complete the installation install the rpm’s: rpm –ivh j2sdk-1_4_1_01-fcs-linux-i586.rpm
  9. You’ll need to update your PATH environment variable to contain the location of the java executables (like java and javac).  You should create the file /etc/profile.d/java.sh and /etc/profile.d/java.csh.  Then do source /etc/profile, and check the value of your PATH variable by doing echo $PATH.

Starting Tomcat:

  1. Move the downloaded Tomcat distribution, jakarta-tomcat-4.0-YYYYMMDD.tar.gz, to /usr/local/. 
  2. cd /usr/local
  3. gunzip jakarta-tomcat-4.0-YYYYMMDD.tar.gz
  4. tar xf jakarta-tomcat-4.0-YYYYMMDD.tar
  5. You should now see a Jakarta-tomcat directory in /usr/local, it's probably called jakarta-tomcat-4.1.18.  You can now delete the .gz and .tar files, if you want.
  6. To start tomcat: cd /usr/local/jakarta-tomcat-4.1.18/bin
  7. Do ./startup.sh

You can test the Tomcat is running by having your browser open http://localhost:8080/. You should see a default Tomcat page. There is a link to JSP and Servlet examples from that page. Try some of them.