Jetty
By Eclipse Foundation
Eclipse Jetty is a Java HTTP server and servlet container designed to be embedded directly inside applications rather than run as a standalone deployment target, making it a common foundation for frameworks like Dropwizard, Javalin, and…
Definition
Eclipse Jetty is a Java HTTP server and servlet container designed to be embedded directly inside applications rather than run as a standalone deployment target, making it a common foundation for frameworks like Dropwizard, Javalin, and Spark Java. It implements the Java Servlet specification and supports HTTP/2, WebSocket, and asynchronous I/O, and is also widely used inside other software products, such as Hadoop and Google App Engine's early Java runtime, as their internal web server.
Overview
Jetty was created to provide a lightweight, embeddable Java web server and servlet container at a time when most Java web serving assumed a standalone application server that applications were deployed into, rather than a library an application could start itself. Its embeddable design — instantiate a `Server` object, configure connectors and handlers, and call `start()` from within a regular Java `main` method — made it a natural fit as the default HTTP layer for microframeworks and tools that wanted to ship a single executable artifact rather than requiring a separately installed server. Mechanically, Jetty is built around a `Server` object that manages one or more `Connector`s (handling the actual network I/O and protocol parsing for HTTP/1.1, HTTP/2, or WebSocket) and a chain of `Handler`s that process incoming requests, with the Servlet API implemented as one particular handler type layered on top of this more general handler architecture. This layered design is why Jetty can serve both traditional servlet-based applications and non-servlet use cases, like being embedded purely as a low-level HTTP server without any servlet container semantics at all, which is part of why it has been adopted inside so many other tools as their internal HTTP layer. Among Java servers, Jetty's main peer for embedded use is Netty, though Netty is a lower-level asynchronous network framework rather than a servlet-aware HTTP server, making Jetty the more direct choice when Servlet API compatibility matters. Compared to Apache Tomcat, the other dominant embeddable Java servlet container (used by default in Spring Boot), Jetty and Tomcat are broadly comparable in capability and performance, with the choice between them often coming down to which framework defaults to which, specific feature needs like Jetty's traditionally strong WebSocket support, or team familiarity. In practice, Jetty is rarely chosen as a standalone deployment target the way a full application server would be; instead, it appears as the embedded HTTP layer inside other software — Dropwizard, Javalin, and Spark Java all use Jetty by default, and various big-data and infrastructure tools have historically embedded it to expose administrative web UIs or APIs without depending on an external server being present. This ubiquity as embedded infrastructure means many developers use Jetty indirectly through a framework without ever configuring it directly. Jetty's main trade-off relative to a full application server is that it provides HTTP and servlet handling only — it does not include EJB containers, JTA transaction management, or other Jakarta EE services, so applications needing those must bring them in separately or choose a framework/server that bundles them. Compared to Tomcat specifically, differences are often marginal enough that migration between the two is usually straightforward, meaning the choice is rarely a hard architectural constraint.
Key Features
- Designed to be embedded directly inside applications as a library
- Implements the Java Servlet specification alongside HTTP/2 and WebSocket support
- Built around a Server object managing Connectors and a Handler chain
- Serves as the default embedded server for Dropwizard, Javalin, and Spark Java
- Supports asynchronous I/O for handling large numbers of concurrent connections
- Used internally by various big-data and infrastructure tools for admin UIs
- Provides low-level HTTP serving even without servlet container semantics
- Maintained as an Eclipse Foundation open-source project