Article:
  Deploying Web Applications to Tomcat
Subject:   A few tips for the Suse newbies...
Date:   2006-03-08 21:13:58
From:   DoctorSuse
THIS IS FOR SUSE 9.1 USERS


Installation:
CSFalcon has alot of good tips on the installation of JDK and Tomcat (get the latest stable versions)


Configuration:
In the /etc folder you should have a file named profile.local. If not create one. This is where you will store environment variables. Use VI editor from the shell while logged in as root to create this file.


Sample profile.local


# Java SDK Path
export JAVA_HOME=/usr/java/jdk1.5.0_06/
export PATH=$PATH:$JAVA_HOME/bin/
# Tomcat Path
export TOMCAT_HOME=/usr/tomcat/jakarta-tomcat-5.0.28
export PATH=$PATH:$TOMCAT_HOME/bin/
# Eclipse Path
export PATH=$PATH:/usr/eclipse
# Alias for Tomcat
alias tom='cd /usr/tomcat/jakarta-tomcat-5.0.28'
# Set CLASSPATH for Jars, etc.
CLASSPATH=$JAVA_HOME/jre/lib
CLASSPATH=$CLASSPATH:/usr/tomcat/jakarta-tomcat-5.0.28/common/lib
CLASSPATH=$CLASSPATH:/usr/tomcat/jakarta-tomcat-5.0.28/common/lib/servlet-api.jar
export CLASSPATH


source profile.local at the prompt to activate these settings. Once you do this everything will fall into place in the tutorial.


TIP! Use the onjava_logo.jpg for your image. Just do a save as on the Tiger and create an images folder under onjava in your Webapps folder.


TIP! Whatever you do, if you have Tomcat 5.x, DO NOT TOUCH the Server.xml file which the instructions tells you to do to setup your Servlet Context. This instruction may have worked for earlier versions of Tomcat, but beware that things change.


TIP! Make sure Network Services are enabled for all services in YaST. I forgot this once and it was days before it occurred to me.


TIP! When you save your files (jsp, xml, etc.) make sure the extension is correct. A common newbie mistake is to have .txt on the end and of course that doesn't work!


TIP! The alias 'tom' in profile.local above makes it possible to go directly to the full path of tomcat with three keystrokes when you're shelling!


TIP! In the case of ONJAVA, you will build a folder structure as follows:


/webapps/onjava/WEB-INF/classes/com/onjava


So under the existing WEB-INF/classes, you should create a COM folder and under that another ONJAVA folder (lowercase for both of these).


Your servlet, login.java will go in this folder.


MAJOR TIP!
This is where to place the Context path:
/usr/tomcat/jakarta-tomcat-5.0.28/conf/Catalina/localhost/onjava.xml


This is a listing of the file:
<Context path="/onjava" docBase="onjava" debug="0" reloadable="true">


</Context>


MAJOR TIP!
This is where to place the Servlet and Servlet mapping:
/usr/tomcat/jakarta-tomcat-5.0.28/webapps/onjava/WEB-INF/web.xml


This is a listing of the file:
<?xml version="1.0" encoding="ISO-8859-1"?>


<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">


<web-app>


<!-- Define servlets that are included in the example application -->


<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.onjava.login</servlet-class>
</servlet>


<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/servlet/com.onjava.login</url-pattern>
</servlet-mapping>



</web-app>


ANY QUESTIONS?!?


DR. SUSE