DEV Community

Sudhakar V
Sudhakar V

Posted on

Apache Tomcat Server

πŸ›°οΈ Apache Tomcat Server and Other Java Servers Explained in Detail


πŸ”Ή What is Apache Tomcat?

Apache Tomcat is a free, open-source web server developed by the Apache Software Foundation. It is not a full Java EE (Jakarta EE) server, but it implements the Java Servlet, JSP, and WebSocket specifications.


βœ… Key Features of Apache Tomcat

Feature Description
Developed by Apache Software Foundation
Type Web server & servlet container (not a full application server)
Supports Java Servlets, JSP (JavaServer Pages), WebSockets
Platform Cross-platform (Linux, Windows, macOS)
Protocols HTTP, HTTPS, AJP
Lightweight Ideal for small-to-medium scale web applications
Easy Deployment WAR file deployment
Embeddable Can be embedded in Java apps (via Spring Boot)
Default Port 8080

βš™οΈ How Tomcat Works

  1. Client sends HTTP request to Tomcat server.
  2. Tomcat maps the request to a servlet or JSP.
  3. Servlet processes the request and generates a response.
  4. Tomcat returns the HTTP response back to the client.

πŸ“ Directory Structure (Brief)

Folder Purpose
bin/ Startup and shutdown scripts
conf/ Configuration files (server.xml)
webapps/ Location to deploy web apps (WAR folders)
logs/ Log files
lib/ Libraries required by Tomcat
work/ Temporary files compiled by JSP engine

πŸš€ Common Alternative Java Servers

Server Type Description
Tomcat Web Server + Servlet Engine Supports servlets, JSP; lightweight and popular
Jetty Web Server + Servlet Engine Lightweight, embeddable, used in tools like Eclipse and Maven
GlassFish Full Java EE Application Server Official reference implementation of Java EE (Jakarta EE)
WildFly (ex-JBoss) Full Java EE App Server High performance, enterprise features, supports clustering
WebLogic Full Java EE App Server Developed by Oracle; powerful but commercial
WebSphere Full Java EE App Server Developed by IBM; enterprise-grade, robust but complex
Undertow Lightweight Web Server Used in WildFly; extremely fast and embeddable
Payara Fork of GlassFish More stable and commercial support available

πŸ”„ Comparison: Tomcat vs Full Application Servers

Feature Tomcat Full Java EE Servers (e.g., WildFly, GlassFish)
Servlet & JSP Support βœ… Yes βœ… Yes
EJB, JPA, JMS Support ❌ No (needs external lib) βœ… Yes
Lightweight βœ… Yes ❌ Heavier
Startup Time Fast Slower
Microservices Ready βœ… With Spring Boot βœ… With configurations
Enterprise Ready ❌ βœ… Yes

πŸ’‘ When to Use What?

Use Case Recommended Server
Simple web app (Servlet/JSP) Apache Tomcat
REST APIs with Spring Boot Tomcat (embedded)
Full Java EE stack (EJB, JMS, JPA, etc.) WildFly / GlassFish
Large enterprise applications WebLogic / WebSphere
Embedded Java server inside application Jetty / Undertow

πŸ“¦ Tomcat and Spring Boot

  • Spring Boot includes an embedded Tomcat server by default.
  • You don’t need to install Tomcat separately β€” just run the main() method.
@SpringBootApplication
public class MyApp {
   public static void main(String[] args) {
      SpringApplication.run(MyApp.class, args);  // Starts embedded Tomcat
   }
}
Enter fullscreen mode Exit fullscreen mode

Would you like a step-by-step example of deploying a Java web app on Tomcat or comparing server performance for a specific use case?

Top comments (0)