What is Tomcat Server

Apache Tomcat Server (called “Tomcat” for short), one of the most popular webserver for Java, is an open-source project that was first released in 1999.

It is an open-source implementation of the Java Servlet, Java Server Pages (JSP), Java Expression Language, and WebSocket technologies. Tomcat provides a “pure Java” HTTP web server environment in which Java code can run. It is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation, released under the Apache License 2.0 license.

Up to tomcat version 6, it was only a web server. but from version 7 onwards it has added multiple facilities like connection pooling support, JNDI registry, and e.t.c. Therefore it also can be called an application server, but it is not really a full application server because it gives only basic features.

  • Latest Version: Tomcat 10.x (Compatible with JDK1.8 or later)
  • Developer(s): Apache Software Foundation
  • Programming languages used: Java
  • Classifications: Application server
  • Default port number: 8080 (changeable)
  • Gives two built-in containers: Servlet Container, JSP container
  • Servlet Container name: CATALINA
  • JSP Container name: JASPER
  • HTTP Connector: Coyote

What is Tomcat Used For & How it works

Tomcat is used for web applications written in Java that don’t require full Java EE specifications but still need a reliable tool. 

We can develop web applications in Java EE technologies and use Tomcat as a web server to automate the web component execution process. The Tomcat server provides one set of Servlet and JSP containers. 

The servlet component is Java-based, whereas JSP components are tags-based components that are internally servlet components. The industry is using both servlets, JSP technologies together in Java web application development. Since JSP is internally using servlet components therefore JSP container runs on top of the Servlet Container.

The life cycle of the servlet component is managed by the Servlet container and the life cycle of the JSP component is managed by both Servlet and JSP containers together. All Java Web Containers (like Servlet Container, JSP Container) internally run on the top of JVM/JRE. Without JVM/JRE a single line of Java code can’t execute.

Tomcat server automates the web application and its web component execution i.e. it listens to client requests continuously 24*7. It takes the request, passes them to appropriate web components, executes them dynamically, gathers the result from them, and sends the results as responses to the browser.

Taking requests from clients (browser), hand-overing requests to containers, gathering results from containers, and delivering those results as responses to the browser is the responsibility of the webserver. But executing the server-side web component, and generating output after processing the request is the responsibility of the web container. Both together should work, then only complete request processing will happen or complete execution of the web component will take place.

In the Servlet Container topic, we have already discussed how a web server and web container works, the tomcat also follows the same process.


There are many features of tomcat server software,

  1. Lightweight:- Tomcat is an incredibly lightweight application. It is very easy to start and stop the tomcat server. It offers only the most basic functionality necessary to run a server. 
  2. Open-Source Software:- It is free and the source code for tomcat server is readily available to anyone.
  3. Well-documented:- Tomcat has a variety of good documentation available, including a wide range of online tutorials that can be viewed or downloaded. 
  4. Highly flexible:- Due to its built-in customization options, extensive and lightweight nature, it offers high flexibility, a user can run it in any fashion he wants, and it will still work as fine without any issues. Since it is open-source, anyone who has knowledge can tweak it according to his requirements.
  5. Stability:- It is one of the most stable platforms available today to build on and use it to run our applications. It is incredibly stable because it runs independently of our Apache installation. In case there is a big failure in Tomcat due to which it has to stop working, the rest of our server would run just well.
  6. Provide an extra level of security:- Depending on how we implement our Tomcat installation, it can add an extra layer of security to the server.

Download Tomcat Server for Windows

Let us see how to install the tomcat server in the Windows operating system. It is recommended to download Windows Service Installer (.exe file) so that it will set up the path/classpath settings itself. You can get the latest version from here.

Download Tomcat WSI

Install Tomcat Server in Windows

Double click on the downloaded “apache-tomcat-<version>.exe” file => Next => Agree the terms and conditions => choose the “Full” installation.

Choose full installation of Tomcat

The full installation of Apache tomcat server will install all available things like- Tomcat, Start Menu Items, Documentation, Manager, Host Manager, and Examples.

Click on next. Now, we can configure the port number, admin username, and password. The default port number of the tomcat server is 8080, therefore it is trying to install on the 8080 port. The 8080 port number may or may not be available, so if you want then you can change it. 

Here we can set the username and password for the tomcat administrator. We will do it later.

Configure port number, username and Password for tomcat server

We don’t want to change anything so let us continue forward, and click on the Next button. 

Tomcat JDK settings

It will pick up the configured JDK in the windows path variable, but if you want to set up another JDK then select it. On my computer JDK-16 is installed therefore it is choosing it. Note:- all the latest tomcat servers are compatible with the JDK1.8+ version (i.e. JDK1.8 or later).

Now set the installation directory where tomcat will be installed. Later this directory will be called <Tomcat_home> directory. In our case the <Tomcat_home> directory = D:\Installed\Web Servers\Tomcat10

Tomcat installation directory setting during installation

Click on the install button. It will take a few seconds to install the Apache Tomcat server. Finally, Apache Tomcat server installation is completed. 

Run Apache Tomcat Server in Windows

Now, let us see how to check if it is installed properly or not. Go to the tomcat installation directory, open <Tomcat_home>/bin folder, and there you can find the “tomcat10.exe” file, double click on this application.

It will start in the command prompt windows, and we will get the last log message something like:-  “org.apache.catalina.startup.Catalina.start Server startup in [9100] milliseconds”. The tomcat server is started, now let us check on the browser. 

Open web browser software and type “localhost:8080”. if you had configured a different port number then use that port number as “localhost:<enter-port-number>”

Tomcat successful installation

To stop the tomcat server just close the windows console where all the log messages are coming.

When we type http://localhost:8080 or localhost:8080 or or then the web browser gives a request using HTTP to the tomcat server which is running on 8080 port number of this current component. As in Java, the current object is referred to as “this” keyword, similarly being from one computer the same computer is referred to as localhost, or its IP address

Startup Settings for Apache Tomcat Server in Windows

When we restart or shut down and start the computer then along with the operating system the tomcat server also started. And when we try to manually start the tomcat server through the “tomcat10.exe” file in <Tomcat_home>/bin folder then the windows console will blink and go. This is happening because the tomcat is also running.

To avoid such problems we should change the startup settings for the Apache tomcat server. Open windows services on your computer (Win Key + S and search “services”). Select Apache tomcat => right-click => Properties.

Startup setting for Tomcat server

There you can see, currently, the startup type = Automatic. Change it to Manual => Apply => OK.

Now, tomcat will start only when we manually start it, and won’t start by the operating system itself while restart/start of the computer.

Tomcat Installation Directory Structure

It is the directory or folder where the tomcat server was installed i.e. <Tomcat_home>. In our case the tomcat installation directory or <Tomcat_home> is D:\Installed\Web Servers\Tomcat10. After installation, we can’t change the installation directory, and in order to do that, you must reinstall the tomcat server.

Tomcat installation directory structure

In the tomcat installation directory, we will discuss which folder contains which type of file.

View and Change Port Number

To view or change the HTTP port number of the tomcat server after installation:-

Go to <Tomcat_home>\conf folder and open the “server.xml” file in any text editor. Search for the first <Connector> tag with the port attribute in this file.

Currently, it is,

<Connector port="8080" protocol="HTTP/1.1"
redirectPort="8443" />

Changing the port number to 2020,

<Connector port="2020" protocol="HTTP/1.1"
redirectPort="8443" />

After changing the port number, save the server.xml file. If the server is already in running mode then we must restart the server else modification can’t reflect. Restarting of the server can be done by closing and starting <Tomcat_home>/bin/Tomcat<ver>.exe file (i.e. which was used to start the tomcat server).

In computer two types of ports are there.
a) Hardware port:- to connect hardware devices with the computer like the mouse, keyboard, Pendrive, and e.t.c. These are physical ports i.e. we can see them.
b) Software port:- to connect software devices with computers. These are logical ports and we can’t see them.

In the windows operating system, we get 1 to 65,536 logical ports. Among these ports from 1 to 1024 port numbers are reserved for the Windows operating system services. 1025 to 65,536 is used for external software. Example:- Oracle s/w, MySQL s/w, tomcat server, and e.t.c. Whenever we install any software then they will try to occupy their default port number but if it is not available (already occupied by other software) then they look for another vacant port number.

SoftwareDefault Port Number

Tomcat servers contain three types of ports. Those are:- connector port, shutdown port, redirect port. All those ports must be valid and unique.

Set, View or Change the Admin Username, Password, and Role

To manage the tomcat server username and password are required. After opening the tomcat server home in the web browser we can see the “Manager App” button which requires a username and password. There you can see all the web applications running on the tomcat web server. From here deployment, undeployment, start, stop, and e.t.c. activities of the web applications will happen.

While installing the tomcat we didn’t set the admin username and password. To set, view, or change the admin username, password, and role of the tomcat server go to <Tomcat_home>\conf folder and open the “tomcat-users.xml” file. If you are setting the username, and password for the first time enter the below details in this file before </tomcat-users> tag,

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

From here itself you can change the username and password. Now, save the file and If the server is already in running mode then restart the server.

Disadvantages of Tomcat

  1. Provides only basic functionalities.
  2. It has some issues like a memory leak.
  3. Issues in the SSL installations.
  4. Its user interface is inferior and basic.
  5. Not good for large traffic.

If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!

Leave a Comment

Your email address will not be published. Required fields are marked *