|
Quick and Dirty “How-to” for configuring Apache Tomcat 4This quick how-to is intended for instructors who would like to use the Apache Tomcat web server and a JSP/Servlet engine for their class. You can find more detailed documentation on the Apache Tomcat website. Before configuring Apache Tomcat, make sure you have J2SDK and Tomcat installed, and the environment variables set up correctly. You can try to startup Tomcat and go to http://localhost:8080 If you see the Tomcat page, then the installation is complete. The main configuration file for Apache Tomcat is server.xml in the path_to_tomcat/conf directory. Open it with a text editor (like notepad). First of all, let’s change the default http binding port to 80 instead of 8080. This way you don’t have to type :8080 at the end of your URL every time. Search for the string port="8080" and then replace 8080 with 80. Notes: Sometimes port 80 can be already taken by another application.
In that case, you can either change settings for the other application, or stay
with port 8080 and add “:8080” at the end of your url when you type it in your
web browser. You can also change the mapping of your default web application directory path_to_tomcat/webapps to some other directory you like. This is useful when you are working in a team, and would like to put the web application directory on a networked directory. Search for the string Host name="localhost" in server.xml and replace that line with the following: <Host name="localhost" debug="0" appBase="your preferred directory" unpackWARs="true"> Replace your preferred directory with the directory of your choice. One very useful feature to add to the above line is reloadable="true". This forces Tomcat to auto-reload servlets whenever you modify them. Otherwise, you would have to restart Tomcat every time you make a change in your servlets. So the above line would look something like this: <Host name="localhost" debug="0" appBase=" your preferred directory" unpackWARs="true" reloadable="true"> Next, search for the string Context path="". Replace that line with: <Context path="" docBase="your preferred directory/ROOT" debug="0"/> Replace your preferred directory with the directory you enter in the previous step. Now save and close the server.xml. Browse to your preferred directory that you enter in the previous step and create the following directories: your preferred directoy/ROOT //put your html and jsp files here Now you can start writing your web application using Apache Tomcat. You can access it by going to http://localhost The web browser will load index.html or index.jsp in your ROOT folder by default.
|