How to Install and Configure Tomcat 8

Apache Tomcat is the most common and popular java-based web container available today. In this tutorial I will show you how to install Tomcat 8 and tweak the configuration files.

How to install and configure Apache Tomcat

How to install and configure Apache Tomcat

Tomcat’s primary advantages are its small footprint, simple configuration, and long history of community involvement. Typically, developers can be up-and-running with a functional Tomcat installation in 5 to 10 minutes, including download time. Tomcat requires very little configuration out-of-the-box to run well on a development machine, but it can also be tuned significantly to perform well in high-load, high-availability production environments. You can create large Tomcat clusters to handle huge volumes of traffic reliably. Tomcat is often used in commercial production environments due to its simplicity and lightweight profile.




Following table shows the Tomcat versions and their specifications

Tomcat version Servlet JSP EL WebSocket Minimum Java version required
3.3.x 2.2 1.1 1.1
4.1.x 2.3 1.2 1.3
5.5.x 2.4 2.0 1.4
6.0.x 2.5 2.1 2.1 5.0
7.0.x 3.0 2.2 2.2 6
8.0.x 3.1 2.3 3.0 1.0 7

Download Tomcat

Go to http://tomcat.apache.org/download-80.cgi and scroll down to “Binary Distributions” -> “Core”. For Windows you can choose between the service installer or the 32-bit or 64-bit ZIP version. If you like to run Tomcat as a Windows service than go for the installer, choose the ZIP download if you want to run the server by hand or integrate with your IDE.

If you run on Linux or OSX download the non-Windows zip, which is just called zip.

Enable Tomcat Manager

The Tomcat manager allows you to easily manage your applications and monitor your server status.

To enable it open the file conf/tomcat-users.xml in your favorite text editor and place following line between the <tomcat-users> and the </tomcat-users> tags :

<user username="admin" password="admin" roles="manager-gui,admin-gui" />

Of course you can set the username and password as you like.

You can access the manager application under http://localhost:8080/manager after you have started the server.

Change Servlet Compiler to use Java 8

By default, Tomcat 8.0 compiles JavaServer Pages (JSP) with Java SE 6 language support even if it runs on Java SE 8. You can change this setting in conf/web.xml file. Search the file for the text org.apache.jasper.servlet.JspServlet. Below the tag that contains this text are two <init-param> tags. Change both values from 1.6 to 1.8

<init-param>
    <param-name>compilerSourceVM</param-name>
    <param-value>1.8</param-value>
</init-param>
<init-param>
    <param-name>compilerTargetVM</param-name>
    <param-value>1.8</param-value>
</init-param>

How to Start and Stop Tomcat Server

Once you did all the configurations you need to start your Tomcat to be able to use it. If you use Windows as hosting OS you may want to check this tutorial first How to set JAVA_HOME in Windows 10 before you proceed with starting the Tomcat server

Starting Tomcat is easy as going to the /bin folder and executing startup.bat for Windows or running startup.sh for Linux or OSX.

You also have the option to start tomcat from within Eclipse IDE. Please refer to this tutorial for more information on how to configure and run Tomcat from eclipse.

To stop Tomcat execute shutdown.bat on your Windows OS or shutdown.sh on Linux or OSX systems.

0 0 votes
Article Rating
guest
0 Comments
Inline Feedbacks
View all comments