Tomcat is used as a server to run Java Servlets. It can be used stand alone or through Apache. Java Servlets is a great language which is very flexible. You can perform balance loading and connect to many great database engines such as postgres. There are many frameworks which you can use to speed up development and keep your code organised, a popular framework is 'struts'.
In this document I will explain how to setup jakarta-tomcat-5.5
The packages and version numbers I will be installing/working with here are:
cd /usr/ports/java/diablo-jdk15/ && make install clean Java will require you to download a heap of files separately through the browser and place them in /usr/ports/distfiles
Install tomcat from ports as the post-install scripts help configure the system faster.
- cd /usr/ports/*/tomcat55
- make install
Used for compiling
- pkg_add -r apache-ant
There is a lot of configuration and tests which you can do in tomcat. Here I'm going to show a basic setup in which you should be able to start some projects.
If you want all the servers to load up on boot here is what you have to add to /etc/rc.conf
Setup Environment Variables
JAVA_HOME=/usr/local/diablo-jdk1.5.0; export JAVA_HOME CATALINA_HOME="/usr/local/tomcat5.5"; export CATALINA_HOME CATALINA_BASE="/usr/local/tomcat5.5"; export CATALINA_BASE CATALINA_TMPDIR="/usr/local/tomcat5.5/temp"; export CATALINA_TMPDIR CLASSPATH="/sbin:/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/usr/local/tomcat5.5/common/lib/servlet-api.jar: /usr/local/tomcat5.5/common/lib/jsp-api.jar:.";export CLASSPATH
Tomcat Servlet Reloading
So that your modifications are automatically reloaded on your development box edit: /usr/local/tomcat5.5/conf/context.xml and change:
First time startup
To start the tomcat server for the first time here is what you do:
shell# cd /usr/local/tomcat5.5/bin shell# bash shell# JAVA_HOME=”/usr/local/diablo-jdk1.5.0”;export JAVA_HOME shell# ./startup.sh
The default for tomcat is http://<ip>:8180 (used to be on port 8080)
The work area is /usr/local/tomcat5.5/webapps
You can enter project_name.war files into the webapps directory then access them like so: