About Me...

Hello world! Me? An eccentric living organism that ponders the supernatural abilities of humanity

Get The Latest Posts

Sign up to get email updates

Tuesday, December 01, 2009

Apache Tomcat: Download, Install and Configure

 Tomcat is a free, open-source servlet/JSP engine that was developed by the Jakarta Project at the Apache Software Foundation and it is the official reference implementation of the servlet/JSP specification set forth by Sun. Tomcat is one of the most popular servlet/JSP engines available for Java web application development. It can be used as both the web server and the servlet engine. I've been using Tomcat for most of my Java web applications. For Tomcat to work properly, it should be able to access the JDK installed on your machine. I assume you are familiar with these and you should have all these components(the Java class library, compiler and the JRE) installed on your machine before you install Tomcat.
 The following procedure is intended for Windows users only but if you are using a different OS, you should be able to install Tomcat with similar steps described here. If you are having trouble with a different OS, I suggest you follow the instructions for that platform.
The current Tomcat version, which is version 6.0.20(at the time of writing) supports JSP2.1 and servlet2.5 specifications.

Follow these steps to install and configure Tomcat

Download and Install Tomcat

  1. Go to http://tomcat.apache.org/ 
  2. Find the Download page for Tomcat6.x 
  3. Scroll down to the Binary Distributions heading(it is also possible to use the source distribution but for the purpose of this article, I'm using the binary distribution)
  4. Under the Core subheading, click on the link for the zip file.
  5. Save it to your hard disk(its name should be something like apache-tomcat-6.0.20.zip).
  6. Extract it and move it to your C drive.
  7. Copy the following .jar files from Tomcat's lib directory(don't move, just copy-paste them) to the JDK's jre\lib\ext directory.
  • servlet-api.jar
  • jsp-api.jar
  • el-api.jar
  • tomcat-dbcp.jar

Set the JAVA_HOME environment variable

In recent versions of Tomcat, the sevlet engine is named Catalina. You will have to change a batch file called catalina.bat in order for this engine to work with JDK.
  1. Open the apache-tomcat-6.0.20(in my case) directory.
  2. Open the directory named bin.
  3. Right-click the catalina.bat file and click "Edit" (this will open the batch file in a Notepad).
  4. Scroll down pass the remarks(they begin with the "rem" keyword).
  5. Immediately after the remarks, enter a "set" statement that sets the JAVA_HOME variable to the directory that contains the JDK of your system.
This is what it looked like when I set it in my machine...(see below)

 set JAVA_HOME=c:\Program Files\Java\jdk1.6.0

you should replace the part in red with the path relevant to your JDK. Don't leave any white space between the assignment operator(=)

     6. Save your changes with catalina.bat file
     7. Start Tomcat and test for some JSP pages.

0 comments:

Post a Comment