How To Install And Configure Apache Tomcat7 Server In Windows


In this article we discuss how to install and configure Apache Tomcat Server and have a look at Apache Tomcat Server.

What is Apache Tomcat

It is an application server or web server or servlet container developed by the Apache Software Foundation (ASF) and released under the Apache License version 2. HTTP web servers provide an environment for Java code to run in. It includes tools for configuration and management, but can also be configured by editing XML configuration files. Most of the modern Java web frameworks are based on servlets and JavaServer Pages and can run on Apache Tomcat, for example Struts, JavaServer Faces, Spring, etcetera.

Apache Tomcat7.0.XX new released

The Apache Tomcat team has released version 7.0.40 of Apache. They removed several fixes that stop Tomcat attempting to parse text, improved handling and reporting if a ConcurrentModificationException occurs while checking for memory leaks, etcetera.

How to Install Tomcat 7

There are certain steps we must follow for configuring Apache Tomcat 7.

Step 1

Download and Install Tomcat

  1. Go to then go to the Binary Distribution/Core/ and download the "zip" package (for example "", about 8MB).
  2. Now unzip the downloaded file into a directory of our choice. Don't unzip onto the dekstop (since its path is hard to locate). I suggest using "e:\myserver". Tomcat will be unzipped into the directory "e:\myserver\tomcat-7.0.40".

Step 2

Check the installed directory to ensure it contains the following sub-directories:

  • bin folder
  • logs folder
  • webapps folder
  • work folder
  • temp folder
  • conf folder
  • lib folder

Step 3

Now, we need to create an Environment Variable JAVA_HOME.

We need to create an environment variable called "JAVA_HOME" and set it to our JDK installed directory.

  1. To create the JAVA_HOME environment variable in Windows XP/Vista/7 we need to push the "Start" button then select "Control Panel" / "System" / "Advanced system settings".  Then switch to the "Advanced" tab and select "Environment Variables" / "System Variables" then select "New" (or "Edit" for modification). In "Variable Name", enter "JAVA_HOME". In "Variable Value", enter your JDK installed directory (e.g., "c:\Program Files\Java\jdk1.7.0_{xx}").
  2. For ensuring that it is set correctly, we need to start a command shell (to refresh the environment) and issue:
    set JAVA_HOME
    JAVA_HOME=c:\Program Files\Java\jdk1.7.0_{xx} <== Check that this is OUR JDK installed directory
  3. Sometimes we need to set JRE_HOME also. So for creating JRE_HOME we need to use the same procedure. Push the "Start" buttonthen select "Control Panel" / "System" / "Advanced system settings".  Then switch to the "Advanced" tab and select "Environment Variables" / "System Variables" then select "New" (or "Edit" for modification). In "Variable Name", enter "JRE_HOME". In "Variable Value", enter your JRE installed directory (e.g., "C:\Program Files\Java\jre7\").

Step 4

Configure Tomcat Server

The configuration files of the Apache Tomcat Server are located in the "conf" sub-directory of our Tomcat installed directory, for example "E:\myserver\tomcat7.0.40\conf". There are 4 configuration XML files:

  1. context.xml file
  2. tomcat-users.xml file
  3. server.xml file
  4. web.xml file

Before proceeding, make a BACKUP of the configuration files.

Step 4(a) "conf\web.xml"; Enabling a Directory Listing

Open the configuration file "web.xml". We shall enable the directory listing by changing "listings" from "false" to "true" for the "default" servlet.

<param-value>true</param-value> like:


Step 4(b) "conf\server.xml file"; set the TCP Port Number

Open the file "server.xml" in a text editor.

The default port number of Tomcat is 8080. Now we need to change the TCP port number for Tomcat, since the same port number can be used by other servers like SQL Server. We may choose any number between 1024 and 65535. We shall choose 9999 in this article.

Locate the following lines, and change port="8080" to port="9999". Like:

<Connector port="9999" protocol="HTTP/1.1" Like


Step 4(c) "conf\context.xml"; Enabling Automatic Reload

In that we set reloadable="true" to the <Context> element to enable automatic reload after code changes.

Add reloadable="true" as in the following:

<Context reloadable="true">
</Context> Like


Step 4(d) (Optional) "conf\tomcat-users.xml"

It is used to manage Tomcat by adding the highlighted lines, inside the <tomcat-users> elements.

In that we can add a password and username as an optional step.

Step 5

Now, start the tomcat server

Executable programs and scripts are kept in the "bin" sub-directory of the Tomcat installed directory, e.g., "E:\myserver\tomcat7.0.40\bin".

Step 5(a) Start Server

Launch a command shell. Set the current directory to "<TOMCAT_HOME>\bin" like E:\myserver\tomcat7.0.40\bin, and run "startup.bat" as follows:


After that a new Tomcat console window appears. Read the messages on the console. Look out for the Tomcat's port number (double check that Tomcat is running on port 9999).......

We saw a figure like:



Step 5(b) Access the Server

Open a browser then enter the URL "http://localhost:9999" to access the Tomcat server's welcome page.

If we get this type of page then it means we are done.


Now try the URL http://localhost:9999/examples to view JSP and servlet examples.

Step 5(c) How to Shutdown Server

We can stop the server using one of the following:

  1. Press ctrl-c on the Tomcat console; or
  2. Run "<TOMCAT_HOME>\bin\shutdown.bat" script:
    // Change the current directory to Tomcat's "bin"
    > e: // Change the current drive
    e:\> cd E:\myserver\tomcat7.0.40\bin // Change Directory to YOUR Tomcat's "bin" directory
    // Shutdown the server
    E:\myserver\tomcat7.0.40\bin> shutdown