Installing Apache Jakarta Tomcat.
I have written it for tomcat 5.0.28 in linux. Please get this, its much better. I think the same will apply for 4 also.
Unzip tomcat bundle in a folder. you will get jakarta-tomcat-xxxx folder which is the main tomcat folder, often refered to as $CATALINA_HOME folder.
Go to CATALINA_HOME/bin, take the file setclasspath.sh and add the following two lines in the beginning
JAVA_HOME=/usr/local/j2sdk1.4.2_03/ --comment-- This is the
java installation folder (j2sdk...)
BASEDIR=/home/aruljose/appl/tomcat/jakarta-tomcat-5.0.28/ --comment-- This is the $CATALINA folder
Go to the user home directory, take the file .bash_profile(a hidden file) and the add the java folder (j2sdk...) to the path. The next line has a sample.
PATH=$PATH:$HOME/bin:/usr/local/Acrobat5/bin:/usr/local/j2sdk1.4.2_03/bin
(I have added to the already existing PATH variable by including $PATH)
Then go to bin of $CATALINA and execute startup.sh you will see the following four lines.
Using CATALINA_BASE: /home/aruljose/appl/tomcat/jakarta-tomcat-5.0.28
Using CATALINA_HOME: /home/aruljose/appl/tomcat/jakarta-tomcat-5.0.28
Using CATALINA_TMPDIR: /home/aruljose/appl/tomcat/jakarta-tomcat-5.0.28/temp
Using JAVA_HOME: /usr/local/j2sdk1.4.2_03/
Once you get these four lines, the web-server is started.
Open the browser and type
http://localhost:8080/ You will see the tomcat page with various documentation details.
Now, how to run a
jsp application with Tomcat.
In $CATALINA_HOME/webapps you will see some folders, they are the applications deployed in tomcat. So to deploy an application create a folder, say 'applicationFolder' inside webapps. then create a WEB-INF directory inside the newfolder which is a must. inside $CATALINA/webapps/applicationFolder, save your jsp file say hello.jsp.
Execute the files shutdown.sh and startup.sh (found in $CATALINA_HOME/bin) subsequently to restart the web-server.
Open the browser and call your file this way
http://localhost:8080/newfolder/hello.jsp You will see the result of your jsp file execution.
Next, setting classpath and path for Java.
This could be done inside .bashrc.
PATH variable should be pointing to the folder that contains all the java executables which compile and run your program.
for example /usr/java/j2sdkxxx/bin/
CLASSPATH variable should be pointing to the folders which contain the *.class files.
see a sample .bashrc file
export PATH=:/usr/kerberos/bin/:/usr/local/bin/:/usr/java/j2sdk1.4.0_01/bin/:/usr/bin/:/bin/:/usr/X11R6/bin/
export JAVA_HOME=/usr/java/j2sdk1.4.0_01/
export CLASSPATH=/usr/java/j2sdk1.4.0_01/
Same procedure is followed to add classpath to the new directories which contain the java class files.
Once this is done, the java files can be compiled and run from anywhere.
About compiling a java file and placing it in another destination directory
<>You can use the following command
java -d destination-dir *.java (to compile all the java files)
for example,
javac -d /home/aruljose/classes NameHandler.java
The path following -d is the destination directory.