Apache Tomcat Tutorial for Java Web Applications
This Apache Tomcat tutorial explains what Tomcat is, what it is used for, how it differs from Apache HTTP Server, and how to install, start, stop, configure, and deploy web applications on Tomcat.
Apache Tomcat is a servlet container and HTTP server for Java web applications. Current maintained Tomcat lines include Tomcat 11.0.x, Tomcat 10.1.x, and Tomcat 9.0.x. Tomcat 11 and 10.1 use Jakarta EE APIs, while Tomcat 9 remains the line for applications that still use Java EE package names.

Apache Tomcat Tutorial – Index
- Introduction to Apache Tomcat
- Apache HTTP Server vs Apache Tomcat
- Apache Tomcat versions for Java EE and Jakarta EE applications
- Apache Tomcat components: Catalina, Coyote and Jasper
- Installation of Apache Tomcat in Ubuntu
- Managing Tomcat
- Deploying Web Applications with Apache Tomcat
- Basic Apache Tomcat security settings
- Apache Tomcat troubleshooting commands
- Apache Tomcat FAQs
Introduction to Apache Tomcat
The Apache Tomcat software is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies.
For beginners, Apache Tomcat is the program that receives a browser request, runs the required Java servlet or JSP code, and sends the HTTP response back to the user. A Java web application usually gets packaged as a WAR file and deployed under Tomcat’s webapps directory or through the Tomcat Manager application.
Apache Tomcat is usually used as a Servlet Container even though Tomcat has a fully functional HTTP Server to serve static content. In most production deployments, Tomcat is used in conjunction with Apache HTTP Server or another reverse proxy where the front-end web server handles TLS, static content, compression, caching, and routing, and forwards Java application requests to Tomcat. This is because Apache HTTP Server supports more advanced web-server options than that of Tomcat.
Tomcat is used for Java web applications that need servlets, JSP pages, WebSocket endpoints, REST APIs built on servlet technology, or frameworks that run on a servlet container. It is not a complete Jakarta EE application server like some enterprise application servers, but it is commonly used when a lightweight servlet/JSP container is enough.
Official reference pages that are useful while learning Tomcat are the Apache Tomcat project home page, the Tomcat version selection page, and the Tomcat migration guide.
Apache HTTP Server vs Apache Tomcat
The phrase “Apache server” can refer to different Apache projects, so it is important to separate Apache HTTP Server from Apache Tomcat.
| Point | Apache HTTP Server | Apache Tomcat |
|---|---|---|
| Main role | General-purpose HTTP web server | Java servlet container and HTTP server |
| Best fit | Static sites, reverse proxy, TLS termination, rewrite rules, load balancing | Java servlets, JSP, WebSocket, servlet-based frameworks |
| Dynamic Java code | Does not run servlets directly | Runs servlet and JSP applications |
| Typical production setup | Faces the internet and proxies selected requests | Runs behind a web server, load balancer, or reverse proxy |
Tomcat can serve static files, but when a site needs advanced HTTP features, administrators often place Apache HTTP Server, Nginx, or a cloud load balancer in front of Tomcat.
Apache Tomcat versions for Java EE and Jakarta EE applications
Choose the Tomcat major version based on the API package names used by your application and the Java version available on your server.
| Tomcat line | API platform | Typical use |
|---|---|---|
| Tomcat 11.0.x | Jakarta EE 11 | Newer applications targeting the latest Jakarta Servlet and JSP APIs |
| Tomcat 10.1.x | Jakarta EE 10 | Modern Jakarta applications using jakarta.* package names |
| Tomcat 9.0.x | Java EE 8 | Existing applications using javax.* package names |
A common migration issue is the package namespace change from javax.* to jakarta.*. If your application was built for Tomcat 8.5 or Tomcat 9, do not move it to Tomcat 10.1 or 11 without checking and updating dependencies, imports, deployment descriptors, and framework versions.
Apache Tomcat components: Catalina, Coyote and Jasper
Apache Tomcat has the following important components and features to manage Java web applications.
- Catalina
- Coyote
- Jasper
- Cluster
- High Availability
- Web Application
Jasper 2 JSP engine in Apache Tomcat
Jasper is the JSP Engine for Tomcat. Jasper is responsible for parsing JSP files and compilation of JSP’s Java code as servlets.
Jasper is capable of background compilation, which means if any changes are made to JSP files, then the older versions of those JSP files are still retained by the server, until the updated JSP files are recompiled.
Catalina servlet container in Apache Tomcat
Catalina is Tomcat’s servlet container. Catalina makes Tomcat a Web Server for dynamic content.
In a deployed application, Catalina loads web application contexts, manages the servlet lifecycle, applies filters, handles sessions, and passes requests to the correct servlet or JSP-generated servlet.
Coyote HTTP connector in Apache Tomcat
Coyote is the component that makes Tomcat capable as a HTTP Web Server. Coyote makes Catalina also act as a server that serves static content.
The Coyote connector listens on ports such as 8080, accepts HTTP requests, and passes them to Catalina. The connector is configured in server.xml.
<Connector port="8080"
protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
The exact connector settings depend on whether Tomcat is directly exposed, running behind a reverse proxy, or running behind a load balancer.
Installing Apache Tomcat on Ubuntu
Before installing Tomcat, check the Java version because Tomcat runs on the JVM. Use a supported Java version for the Tomcat line you install.
java -version
On Ubuntu, the package name depends on the Ubuntu release and repository. For example, older Ubuntu releases provided tomcat8, while newer systems may provide newer Tomcat packages or require a manual installation from the Apache Tomcat download page.
sudo apt update
apt-cache search '^tomcat[0-9]+$'
To install Tomcat on Ubuntu, you could use command line interface and run the following command. The example below shows the older tomcat8 package name; replace it with the Tomcat package available for your Ubuntu version when needed.
$ sudo apt-get install tomcat8
~$ sudo apt-get install tomcat8
[sudo] password for arjun:
Reading package lists... Done
Building dependency tree
Reading state information... Done
.
.
Setting up tomcat8 (8.0.32-1ubuntu1.4) ...
If you need an older project-specific Tomcat release, install the package or archive that matches that project. Avoid choosing Tomcat 7 or Tomcat 8.5 for a new application unless you have a clear compatibility requirement and a maintenance plan.
Following are the useful locations that we may need in further steps. These paths can vary between package-based installations and manually extracted Tomcat archives.
- /etc/tomcat{X} for configuration
- /usr/share/tomcat{X} for runtime, called CATALINA_HOME
- /usr/share/tomcat{X}-root for webapps
- /var/lib/tomcat{X}/webapps is also commonly used as the webapps directory in package-based installations
- /var/log/tomcat{X} stores logs in many Linux package installations
You could check if the Tomcat server is running, by opening a browser and hitting the url http://localhost:8080/. Something similar to the following would be responded back with.

Start Apache Tomcat
Once you install Tomcat from Ubuntu packages, it is usually started automatically.
In case if you have stopped it manually, and would like to start Apache Tomcat again, open a terminal and run the following command.
$ sudo /etc/init.d/tomcat8 start
~$ sudo /etc/init.d/tomcat8 start
[ ok ] Starting tomcat8 (via systemctl): tomcat8.service.
On modern Linux systems that use systemd, you may also start the Tomcat service with systemctl. Replace tomcat9 with your installed service name.
sudo systemctl start tomcat9
sudo systemctl status tomcat9
Restart Apache Tomcat
There could be scenarios, like you have updated your web-application, where you may need to restart Apache Tomcat for the server to pick up the changes.
To restart Apache Tomcat, Open a Terminal and run the following command.
$ sudo /etc/init.d/tomcat8 restart
~$ sudo /etc/init.d/tomcat8 restart
[ ok ] Restarting tomcat8 (via systemctl): tomcat8.service.
With systemd, use the following command.
sudo systemctl restart tomcat9
Stop Apache Tomcat
To stop Apache Tomcat, open a terminal and run the following command.
$ sudo /etc/init.d/tomcat8 stop
If you have installed a different Tomcat package, use that service name instead of tomcat8 in the above command.
~$ sudo /etc/init.d/tomcat8 stop
[ ok ] Stopping tomcat8 (via systemctl): tomcat8.service.
With systemd, use the following command.
sudo systemctl stop tomcat9
Deploying Static and Dynamic Web Applications with Apache Tomcat
In the following sections, we shall learn to deploy static and dynamic web applications in Tomcat.
Deploying Static Web-Applications with Apache Tomcat
To deploy static web application with Tomcat, all you need to do is copy your project folder to tomcat web-apps directory.
For Linux :
~$ sudo cp -a StaticWebProject/ /usr/share/tomcat8-root/
~$ cd /usr/share/tomcat8-root/
/usr/share/tomcat8-root$ ls
default_root StaticWebProject
/usr/share/tomcat8-root$ cd StaticWebProject/
/usr/share/tomcat8-root/StaticWebProject$ ls
another_page.html index.html
Now restart Tomcat for the changes to take effect.
~$ sudo /etc/init.d/tomcat8 restart
[ ok ] Restarting tomcat8 (via systemctl): tomcat8.service.
Open a browser, and hit the url, http://localhost:8080/StaticWebProject.
On many Linux package installations, the deployment directory may be /var/lib/tomcat9/webapps or a similar versioned path. Check your service documentation and the value of CATALINA_BASE if the copied application does not appear.
Deploying Dynamic Web-Applications with Apache Tomcat
.war is the format of the web application that Apache Tomcat Server could deploy. If you are building a web application using an IDE like Eclipse, IntelliJ IDEA, NetBeans, Maven, or Gradle, you could export or build the application as a WAR file.
A typical deployment flow is to build the WAR file, copy it to the Tomcat webapps directory, and restart or reload the application. Replace myapp.war and the Tomcat version path with your actual file and installation path.
sudo cp target/myapp.war /var/lib/tomcat9/webapps/
sudo systemctl restart tomcat9
After deployment, Tomcat normally expands the WAR into a directory with the same base name. For example, myapp.war becomes available at a URL similar to http://localhost:8080/myapp/.
Basic Apache Tomcat security settings after installation
A new Tomcat installation should not be treated as production-ready without review. At minimum, check access to the Manager application, default users, connector exposure, file permissions, and update policy.
- Do not expose the Tomcat Manager or Host Manager applications to the public internet.
- Use strong, unique credentials in
tomcat-users.xmlif the Manager application is enabled. - Run Tomcat as a dedicated service user, not as
root. - Keep Tomcat, Java, and operating system packages updated.
- Use HTTPS at the reverse proxy or load balancer, or configure TLS carefully if Tomcat terminates HTTPS directly.
- Remove sample applications from production servers if they are not required.
- Review logs regularly for failed deployments, connector errors, and repeated unauthorized requests.
For production, place Tomcat behind a reverse proxy or load balancer when your architecture needs centralized TLS, request routing, caching, compression, or multiple application instances.
Apache Tomcat troubleshooting commands for common startup issues
If Tomcat does not start or an application returns an error page, start with the service status, logs, Java version, and port usage.
sudo systemctl status tomcat9
journalctl -u tomcat9 --no-pager -n 100
java -version
ss -ltnp | grep ':8080'
Common causes include another process already using port 8080, an unsupported Java version, a broken WAR file, wrong file permissions, missing environment variables, or application code that fails during startup.
Apache Tomcat tutorial summary for beginners
Apache Tomcat is used to run Java web applications based on servlet, JSP, WebSocket, and related technologies. Use Tomcat 9 for applications that still depend on Java EE javax.* APIs, and use Tomcat 10.1 or 11 for applications built for Jakarta EE jakarta.* APIs. For production, review version compatibility, service management, deployment paths, logs, security settings, and reverse proxy configuration before exposing an application to users.
Apache Tomcat FAQs
What is Apache Tomcat for beginners?
Apache Tomcat is a server program for Java web applications. It receives HTTP requests, runs Java servlet or JSP code, and sends responses back to the browser.
What is Apache Tomcat used for?
Apache Tomcat is used to deploy and run Java web applications, servlet-based REST APIs, JSP pages, WebSocket applications, and frameworks that need a servlet container.
What is the difference between Apache HTTP Server and Apache Tomcat?
Apache HTTP Server is a general web server and reverse proxy. Apache Tomcat is a Java servlet container that runs Java web applications. They can be used together, with Apache HTTP Server in front and Tomcat running the Java application behind it.
Is Apache Tomcat still used?
Yes. Apache Tomcat is still maintained, and current release lines continue to receive updates. Choose the supported Tomcat line that matches your application’s Java EE or Jakarta EE requirements.
Which Apache Tomcat version should I use for a new project?
For a new Jakarta EE project, use a currently maintained Tomcat 10.1.x or 11.0.x line depending on the API level your framework supports. Use Tomcat 9.0.x mainly when the application still depends on Java EE javax.* package names.
Apache Tomcat editorial QA checklist
- Does the tutorial distinguish Apache HTTP Server from Apache Tomcat clearly?
- Does the version guidance avoid presenting Tomcat 8.5 as the current recommended line?
- Do installation commands explain that package names and paths vary by Ubuntu release?
- Do all new command examples use PrismJS-compatible
language-bashblocks and output examples use output-style blocks? - Does the deployment section explain both static folders and WAR deployment?
- Does the security section warn against exposing the Manager application publicly?
- Do FAQ answers directly match beginner search intent for Tomcat usage, version choice, and Apache-vs-Tomcat confusion?
TutorialKart.com