Generated by GPT-5-mini| Jakarta Servlet | |
|---|---|
| Name | Jakarta Servlet |
| Initial release | 1997 |
| Developer | Sun Microsystems; now Eclipse Foundation |
| Latest release | Jakarta Servlet 6.0 (API aligned with Jakarta EE 10) |
| Written in | Java (programming language) |
| Platform | Java Platform, Enterprise Edition / Jakarta EE |
| License | Eclipse Public License / open source |
| Website | Eclipse Foundation |
Jakarta Servlet is a server-side component model and API specification for handling Hypertext Transfer Protocol requests and generating responses in Java (programming language) web applications. It defines a contract for pluggable components that process HTTP traffic inside web server and application server environments, enabling integration with technologies such as JavaServer Pages, WebSocket, and Jakarta RESTful Web Services. The specification is governed by the Eclipse Foundation as part of the Jakarta EE platform and is implemented by multiple vendors and open-source projects.
The specification specifies interfaces and abstract classes that allow developers to write reusable components executed by a servlet container embedded in servers like Apache Tomcat, Eclipse Jetty, GlassFish, and WildFly. Servlets operate within a container-managed runtime that provides lifecycle management, threading, concurrency, session management, and integration with Java Naming and Directory Interface for resource lookup. Jakarta Servlet is central to the Jakarta EE web tier, interoperating with APIs such as Jakarta Expression Language, Jakarta Faces, and Jakarta Security to build enterprise web applications.
The technology originated under Sun Microsystems during the late 1990s as part of the original Java Platform, Enterprise Edition efforts. Early iterations standardized servlet behavior across containers, enabling portability across implementations like Apache Tomcat and Jetty. Following the corporate restructuring surrounding Oracle Corporation and subsequent vendor collaborations, stewardship moved to the Eclipse Foundation and the branding transitioned as part of the Jakarta EE initiative. Major milestones include alignment with newer HTTP features, modularization for Java Platform Module System, and package namespace migration to support the Jakarta EE trademark and ecosystem.
A servlet-based web application is composed of servlets, filters, listeners, and deployment descriptors. The servlet container (often inside an application server such as GlassFish or a servlet engine like Apache Tomcat) provides request routing, multithreaded execution, and lifecycle callbacks. Filters offer request/response transformation points integrated into the pipeline, while listeners receive container events from components such as HttpSession and application startup. Configuration can be expressed in deployment descriptors or programmatic registration using container APIs, enabling integration with component models such as OSGi in modular environments.
Key types in the specification include the servlet interface hierarchy and HTTP-specific contracts. The foundational types include javax.servlet equivalents migrated under the Jakarta namespace and define entities such as generic servlet base classes, HTTP request and response wrappers, session abstractions, and context objects. Important interfaces and classes used across implementations include servlet context, request dispatcher, session management APIs, and multipart request support. These APIs are designed to interoperate with other Jakarta EE specs including Jakarta Transactions, Jakarta Persistence, and Jakarta Security for enterprise concerns like transaction propagation and authentication.
The container controls the lifecycle: loading, initialization, request servicing, and destruction. Servlets receive initialization parameters and are instantiated once (or managed via pooling) before the container invokes service methods for each request thread. For HTTP processing, the container dispatches requests to doGet, doPost, and related handlers, providing access to headers, cookies, input streams, and asynchronous processing primitives. Asynchronous request handling and non-blocking IO support allow integration with server push and streaming scenarios, while session lifecycle events let applications react to user session creation, passivation, and invalidation. Request dispatch mechanisms include forwarding and including resources via request dispatcher semantics.
Security features integrate container-managed authentication, authorization, and transport guarantees. The specification defines programmatic and declarative configuration points for role-based access constraints, security realms, and login mechanisms that integrate with container providers such as Keycloak or platform-native realms. Configuration options include deployment descriptors, annotations, and runtime container administration tools; these control aspects such as URL pattern mapping, multipart file upload constraints, and initialization parameters. Secure coding guidance recommends explicit input validation, proper session invalidation, and adherence to container-provided mechanisms for credential handling and TLS termination.
Multiple servlet containers and application servers implement the specification, including Apache Tomcat, Eclipse Jetty, GlassFish, WildFly, and commercial vendors like IBM WebSphere variants and Oracle WebLogic Server. Compatibility is maintained via TCK-driven conformance testing overseen within the Jakarta EE community at the Eclipse Foundation. Versions of the specification evolve to reflect modern web standards and Java language changes, and implementers provide extensions for performance, clustering, and management features such as JMX integration or native session replication. Migration paths exist from legacy javax namespaces to Jakarta namespaces, and tooling in build ecosystems like Maven (software) and Gradle assists projects in targeting specific container distributions and API versions.