The Java Servlet API is the standardized set of interfaces and contracts through which Java web components (servlets) communicate with a servlet container. The container handles the servlet’s lifecycle and its request/response interactions. In current releases the API lives in the jakarta.servlet namespace; older Java EE generations use javax.servlet.
What the Servlet API actually is
Oracle’s Java EE 7 reference describes the javax.servlet package as the classes and interfaces that define the contracts between a servlet class and its runtime environment in a conforming servlet container (Oracle, javax.servlet package summary). The Jakarta Servlet specification is the standard for the current Jakarta API, and it points readers to the specification and Javadoc for exact class, interface and method signatures (Jakarta Servlet Specification 6.1).
As an Amazon Associate I earn from qualifying purchases.
Three terms are related but not interchangeable:
- Servlet: the web component, a Java class that generates dynamic content.
- Servlet API: the contract that the servlet implements and uses.
- Servlet container: the runtime that supplies services and connects the servlet to web clients.
The API is not a web server. It defines types and behavior; a container implements the runtime side.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallWhat the container does
The Jakarta Servlet 6.1 specification defines a servlet as a container-managed web component that generates dynamic content and interacts with web clients through a request/response model. The container is part of a web or application server, or can be installed as an add-on. It supplies network services, decodes MIME-based requests, formats MIME-based responses, and manages the servlet lifecycle (specification, overview).
In practice the flow is:
- A client request reaches the server and its container.
- The container maps the request to the relevant servlet and dispatches it.
- The servlet reads the request and builds a response.
- The container returns the response to the client.
Servlet lifecycle
The Servlet interface documentation describes three phases: construction and initialization, servicing of requests, and removal from service followed by destruction. You can implement the interface directly, extend GenericServlet for a protocol-independent servlet, or extend HttpServlet for an HTTP servlet (Jakarta EE 8 API reference, Servlet).
The HTTP-specific types
Oracle’s Java EE 7 documentation for the HTTP package describes these core abstractions (javax.servlet.http package summary):
Rank #2
| Type | Role |
|---|---|
HttpServletRequest |
Provides request information to the servlet |
HttpServletResponse |
Provides HTTP-specific response functionality |
HttpSession |
Identifies a user across multiple page requests or visits and stores information about them |
javax.servlet versus jakarta.servlet
Java EE-era APIs use javax.servlet. Jakarta Servlet 5.0 and later use jakarta.servlet. The 6.1 specification states that migrating a Servlet 4.0 project to 5.0 or above requires replacing javax.* with jakarta.*. This is a package namespace change in source code, and the target runtime must support the API generation your application uses.
The official Jakarta Servlet page lists version 6.1 as a final release dated March 28, 2024, with Maven coordinates jakarta.servlet:jakarta.servlet-api:6.1.0 and a listed compatible implementation (Jakarta Servlet 6.1).
Choosing an API generation
When comparing generations or runtimes, check:
- the namespace (
javaxorjakarta); - the specification version;
- the required Java SE level;
- container compatibility;
- the migration work involved.
No generation is universally better; the right one depends on the container you deploy to.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Where to read the normative details
The specification itself says: “We emphasize that this specification is not a user’s guide for servlet developers and is not intended to be used as such.” Use it, together with the Javadoc, as the authority on behavior and signatures, and use tutorials for learning.
Quick Recap
Best Value
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →




