Working with Tomcat 10
![]() |
Tomcat Logo |
This blog has been inspired since we're upgrading our existing Tomcat 8 servers to Tomcat 10.
First off, what's Tomcat anyway?
The following is the definition you'd find on the Tomcat site [1]:
The Apache Tomcat® software is an open source implementation of the Jakarta Servlet, Jakarta Pages, Jakarta Expression Language, Jakarta WebSocket, Jakarta Annotations and Jakarta Authentication specifications.
![]() |
My face after reading the above definition |
The problem with the above definition is that I don't understand what it actually is. Like most people I used to think that it's just a 'web server' BUT it's not quite a full-fledged web server like Apache HTTP Server (httpd) or Nginx.
It is primarily a 'servlet container' that executes Java Servlets and JavaServer Pages (JSP) with some web capabilities. It does NOT support features like reverse proxying, caching, or load balancing.
A Java Servlet is a Java class that handles HTTP requests and generates responses dynamically. It runs inside a Servlet container (e.g., Apache Tomcat) and is part of the Jakarta Servlet API (formerly Java Servlet API).
JSP (JavaServer Pages) is a template-based technology that allows embedding Java code inside HTML to generate dynamic content. It’s easier for UI development compared to Servlets.
Servlets handle requests, process data, and forward results to JSP. JSP is used for rendering dynamic HTML with processed data.
JSP is still used in legacy Java web applications, but newer projects often prefer Spring Boot + Thymeleaf/React/Angular.
Spring Boot applications by default use Apache Tomcat as their embedded web server. This means we don't need to install or configure Tomcat separately to run a Spring Boot web application.
By default, Spring Boot creates a fat JAR that contains embedded Tomcat, but we can package it as a .war file for deployment on an external Tomcat server.
Installing Tomcat
$ sudo yum install -y java-21-openjdk
$ sudo groupadd tomcat
$ sudo useradd -g tomcat -d /opt/tomcat -s /bin/nologin tomcat
$ wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.35/bin/apache-tomcat-10.1.35.tar.gz
$ mkdir /opt/tomcat
Set permissions. If the commands below don't work - try to 'sudo su -' into root user and then running the commands.
$ cd /opt/tomcat
$ sudo chgrp -R tomcat /opt/tomcat
$ sudo chmod -R g+r conf
$ sudo chmod g+x conf
$ sudo chown -R tomcat webapps/ work/ temp/ logs/
Configure it as a systemd service
$ sudo vi /etc/systemd/system/tomcat.service
Then, reload systemd daemons & start tomcat server:
$ sudo systemctl daemon-reload
$ sudo systemctl start tomcat
$ sudo systemctl enable tomcat
Allow Tomcat webserver default port through firewall:
$ sudo firewall-cmd --permanent --add-port=8080/tcp
$ sudo firewall-cmd --reload
Running a sample application
Creating a simple "Hello World" WAR
![]() |
Tomcat manager |
References:
[1] https://tomcat.apache.org/
[2] https://tomcat.apache.org/download-10.cgi
[3] https://chatgpt.com/c/67acd2dc-aafc-8012-a885-efd305ac190c
Comments
Post a Comment