Jetty, also known as Eclipse Jetty, is an open-source Java web server and servlet container that serves HTTP traffic and runs Java web applications built on the Jakarta Servlet specification. Among web servers it stands out because it is designed to be embedded inside an application as a library rather than installed only as a standalone daemon, which makes it a common building block on Java servers.
Jetty is maintained under the Eclipse Foundation and supports HTTP/1.1, HTTP/2, HTTP/3 and WebSocket. It appears in build tools, IDEs, data platforms and microservices, often without users realizing that a Jetty instance is answering their requests.
How Jetty handles HTTP requests
Jetty processes requests through a chain of connectors, a thread pool and handlers. A connector listens on a network port, accepts TCP or QUIC connections and parses the protocol, while a handler tree decides what to do with each request, for example serving a static file, applying a rewrite rule or passing control to a servlet.
The I/O core is asynchronous and non-blocking, built on Java NIO selectors. A connection that is idle does not occupy a thread, so a single Jetty instance can keep tens of thousands of open connections while using a bounded thread pool. Threads are borrowed only when there is work to do, such as reading a request body or running application code.
The main architectural building blocks are summarized below.
| Component | Role | Typical configuration |
|---|---|---|
| Server | Top-level container that owns everything else | One per JVM process in most deployments |
| Connector | Accepts connections and decodes the protocol | HTTP on 8080, TLS on 8443, HTTP/2 or HTTP/3 factories |
| QueuedThreadPool | Supplies worker threads for request processing | Roughly 8 to 200 threads, tuned to workload |
| Handler | Processes or routes a request | Context, resource, rewrite and gzip handlers |
| ServletContextHandler | Hosts servlets and filters for one context path | One per web application or API |
| WebAppContext | Deploys a full WAR file with its descriptor | Used in standalone, Tomcat-style setups |
Embedded and standalone deployment modes
Jetty can run in two distinct ways, and the choice shapes how an application is built and operated. In embedded mode, the application includes Jetty as a dependency, creates a Server object in its main method and starts it, so the application owns the server. In standalone mode, administrators unpack the Jetty distribution, configure modules in a jetty-base directory and deploy WAR files into it, so the server owns the applications.
Embedded use dominates modern practice because it fits self-contained executable JAR files, container images and twelve-factor style services. Spring Boot, for example, can use Jetty as its embedded server instead of the default Apache Tomcat with a dependency change.
| Aspect | Embedded mode | Standalone mode |
|---|---|---|
| Startup | Started from application code | Started by the start.jar launcher |
| Configuration | Java code or framework properties | Module files and XML in jetty-base |
| Packaging | Single executable JAR or image | WAR files deployed into the server |
| Upgrades | Rebuild the application | Replace jetty-home, keep jetty-base |
| Best fit | Microservices and tools | Several legacy WAR applications on one host |
Jetty compared with related web servers
Jetty belongs to the family of Java servlet containers, so its closest neighbor is Apache Tomcat, while general-purpose web servers such as Nginx and Apache HTTP Server solve a different problem. Nginx cannot run Java code itself; it typically sits in front of Jetty as a reverse proxy that terminates TLS, caches static assets and balances load.
The following comparison highlights where Jetty fits among common server technologies.
| Server | Primary language | Main strength | Typical role |
|---|---|---|---|
| Jetty | Java | Small footprint and easy embedding | Embedded server in Java applications |
| Apache Tomcat | Java | Mature reference-style servlet container | Standalone or embedded Java web server |
| Undertow | Java | Lightweight non-blocking core | Embedded server in WildFly and Quarkus setups |
| Nginx | C | Very efficient static serving and proxying | Edge proxy in front of application servers |
| Gunicorn | Python | Simple pre-fork WSGI serving | Application server for Python frameworks |
Jetty is not a full application server in the Jakarta EE sense. It implements the Servlet, WebSocket and JSP pieces but does not provide EJB, JTA or full messaging stacks, which keeps it lean and fast to start.
Versions and specification support
Each major Jetty version targets a specific Java baseline and servlet generation, so version selection is a compatibility decision. The move from the javax.servlet namespace to jakarta.servlet is the most important break: applications compiled against the old namespace need Jetty 9.4 or the EE8 environment, or a migration of their imports.
| Jetty version | Minimum Java | Servlet support | Status |
|---|---|---|---|
| Jetty 9.4 | Java 8 | Servlet 3.1, javax namespace | End of community support |
| Jetty 10 | Java 11 | Servlet 4.0, javax namespace | End of community support |
| Jetty 11 | Java 11 | Servlet 5.0, jakarta namespace | End of community support |
| Jetty 12 | Java 17 | EE8, EE9 and EE10 environments | Current maintained line |
Jetty 12 introduced a redesigned core in which servlet support is an optional layer. The same server can host applications for several Jakarta EE generations side by side, and lightweight services can run on the core handler API with no servlet container at all.
Tuning, security and common pitfalls
Most production problems with Jetty come from thread pool sizing, timeouts and outdated versions rather than from the server design. Because Jetty is frequently hidden inside another product, teams often run an unpatched embedded Jetty without knowing it, which has made Jetty vulnerabilities a recurring item in dependency scanning reports.
| Symptom | Likely cause | Recommended fix |
|---|---|---|
| Requests queue under load | Thread pool too small for blocking code | Raise maxThreads or move blocking calls off request threads |
| Connections dropped after 30 s | Idle timeout shorter than client behavior | Align idleTimeout with proxy and client timeouts |
| Large uploads rejected | Form or request size limits | Adjust maxFormContentSize or use multipart limits |
| Scanner flags old CVEs | Outdated embedded Jetty dependency | Upgrade to a maintained Jetty 12 release |
| ClassNotFound for javax.servlet | Namespace mismatch after upgrade | Use the EE8 environment or migrate to jakarta |
- Terminate TLS deliberately: either in Jetty with a modern cipher configuration or at a reverse proxy, never inconsistently in both.
- Disable directory listing and remove default context handlers in production.
- Set request header size limits to reduce exposure to oversized header attacks.
- Track the Jetty version inside every product that embeds it, not only in your own code.
In everyday language
Jetty is a piece of software that lets a Java program talk to web browsers and other programs over the internet. When someone opens a page, Jetty receives the request, hands it to the right part of the program and sends the answer back.
What makes it special is that Jetty can live inside the program itself. Instead of setting up a separate web server and installing an application on it, developers can simply include Jetty, much like adding a built-in engine to a vehicle rather than towing it behind. The key idea is a small, embeddable web server for Java.
Seen in the real world
A logistics company runs a fleet-tracking API written in Java. The team packages each service as a container image that contains a single executable JAR with embedded Jetty 12, listening on port 8080 behind an Nginx reverse proxy that handles TLS and rate limiting. Each container uses a thread pool of 200 threads and an idle timeout of 60 seconds to match the proxy configuration.
During a quarterly dependency scan, the security team also finds an old Jetty 9.4 library inside a third-party reporting tool. They upgrade the tool to a release built on a maintained Jetty line, and the API services handle peak traffic of about 3,000 requests per second with stable latency and no unpatched server components.