Tomcat
By Apache Software Foundation
Apache Tomcat is an open-source Java servlet container that implements the Jakarta Servlet, JavaServer Pages, and WebSocket specifications, giving Java web applications a runtime environment for handling HTTP requests. It runs as a…
Definition
Apache Tomcat is an open-source Java servlet container that implements the Jakarta Servlet, JavaServer Pages, and WebSocket specifications, giving Java web applications a runtime environment for handling HTTP requests. It runs as a standalone HTTP server or embedded inside an application, translating incoming requests into servlet method calls and returning generated responses, and is one of the most widely deployed platforms for running Java-based web applications and APIs.
Overview
Tomcat began as the reference implementation for Sun's servlet and JSP specifications and has since become the de facto standard container for deploying Java web applications outside full Java EE application servers. It sits below frameworks such as Spring MVC and JavaServer Faces, providing the low-level machinery — thread pools, connectors, session management, and class loading isolation — that those frameworks build on top of. Because it implements only the web tier of the Jakarta EE umbrella rather than the full platform, it is lighter to install and operate than servers like WildFly or GlassFish. Mechanically, Tomcat listens on one or more connectors, each bound to a protocol such as HTTP/1.1, AJP, or HTTP/2, and each request is routed through a chain of valves and filters before reaching the target servlet. Deployments are packaged as WAR files placed in a webapps directory, or in embedded mode a Java application starts a Tomcat instance programmatically and registers servlets in code, a pattern popularized by Spring Boot's default embedded server. Each deployed application runs in its own class loader, which isolates dependency versions between applications sharing one Tomcat instance, though this isolation also causes classic classpath conflicts that trip up developers new to the platform. Among Java web servers, Tomcat occupies a middle ground: it is heavier and more feature-complete than a bare async server like Netty, but far lighter than a full application server that also provides EJB containers, JMS brokers, and distributed transaction managers. Undertow and Jetty compete directly with it as embeddable servlet engines, generally trading some feature completeness for a smaller footprint or different threading models. Tomcat's session replication and clustering support, while functional, is less commonly used today than externalizing session state to Redis or a database in stateless architectures. In practice, most developers encounter Tomcat indirectly, as the default embedded server bundled with Spring Boot, or as the deployment target when packaging a WAR for a shared corporate server. Operations teams tune its thread pool sizes, connector timeouts, and JVM heap settings to handle production load, and configure the server.xml file to add SSL connectors, virtual hosts, or access logging. It is also common in legacy enterprise environments where a JSP-based application was written a decade or more ago and has not been migrated to a newer stack. Tomcat's limitations show up mainly in newer, cloud-native contexts: its thread-per-request model does not scale as efficiently under extremely high concurrent connection counts as fully asynchronous, event-loop based servers, and its configuration surface (server.xml, context.xml, web.xml) feels dated next to code-first configuration in modern frameworks. Teams building reactive applications with Spring WebFlux typically swap in Netty instead. For traditional synchronous servlet-based applications, however, Tomcat remains a stable, well-documented, and low-maintenance choice.
Key Features
- Implements the Jakarta Servlet, JSP, and WebSocket specifications
- Runs standalone or embedded inside a Java application process
- Isolates each deployed WAR in its own class loader
- Configurable connectors for HTTP/1.1, AJP, and HTTP/2 protocols
- Supports session clustering and replication across nodes
- Extensible through valves and filters in the request pipeline
- Ships as the default embedded server in Spring Boot
- Provides built-in access logging and JMX-based monitoring hooks