Latest in branch 6.0
6.0.0
Released 12 May 2022
(4 years ago)
SoftwareServlet/Jakarta Servlet
Version6.0
Initial release6.0.0
12 May 2022
(4 years ago)
Latest release6.0.0
12 May 2022
(4 years ago)
PlatformJakarta EE 10
Source codehttps://github.com/jakartaee/servlet/tree/6.0.0-RELEASE
Documentationhttps://javadoc.io/doc/jakarta.servlet/jakarta.servlet-api/6.0.0/index.html
Downloadhttps://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api/6.0.0
Servlet/Jakarta Servlet 6.0 ReleasesView full list

What Is New in Servlet 6.0

Jakarta Servlet 6.0 is a major release that aligns the specification with Jakarta EE 10 and introduces several key updates. The focus is on modernizing the API and improving developer experience.

Category Key Changes
Core API Updates Migration to the jakarta.servlet namespace, removal of deprecated APIs.
HTTP Protocol Support for HTTP/2 trailer fields, new methods for RFC 6265 compliant cookies.
Error Handling New default error page for deployment descriptors.
Clarifications Refined specifications for ServletContext initialization parameters and request dispatchers.

How does the namespace change affect my existing applications?

The most significant change is the final migration from javax.servlet to jakarta.servlet. This is a breaking change for all existing applications. You'll need to update all your import statements and any Maven/Gradle dependencies to use the new Jakarta coordinates.

In practice, this means a simple find-and-replace operation in your codebase, but it's a mandatory step for moving to Servlet 6.0 and Jakarta EE 10. Your build configuration must now point to artifacts like jakarta.servlet:jakarta.servlet-api:6.0.0.

What new HTTP features are available for modern protocols?

Servlet 6.0 adds explicit support for working with HTTP/2 trailer fields. You can now check if a trailer field is available using HttpServletRequest.isTrailerFieldsAvailable() and retrieve them with getTrailerFields().

This matters because it allows servlets to fully participate in HTTP/2 communication, reading trailing headers that are sent after the request body. It brings the API in line with modern web standards.

How has cookie handling been improved?

The specification now mandates RFC 6265 compliance for cookie handling. New methods like Cookie.setAttribute() and getAttribute() have been added for managing cookie attributes in a standard way.

This replaces the old setComment() and getComment() methods, which are now deprecated. The change ensures more consistent and standards-compliant behavior across different servlet containers.

What clarifications were made for deployment and configuration?

The handling of ServletContext initialization parameters has been clarified. The specification now explicitly states that a container must make these parameters available to the application before any servlet initialization occurs.

Additionally, a default error page is now defined for use in deployment descriptors, simplifying error handling configuration. The semantics of the include() method on RequestDispatcher have also been refined for greater predictability.

FAQ

Is Servlet 6.0 backwards compatible with my old javax.servlet code?
No. The change from javax.servlet to jakarta.servlet is a breaking change. You must update all import statements and dependencies to migrate an application to Servlet 6.0.

What is the practical use of the new HTTP/2 trailer fields API?
It allows servlets to read trailing headers sent after the request body in an HTTP/2 stream. This is essential for properly handling gRPC requests and other protocols that use trailing headers for metadata or checksums.

Why were the old Cookie methods like setComment() deprecated?
They were deprecated to enforce RFC 6265 compliance. The new setAttribute() and getAttribute() methods provide a more standardized and flexible way to handle all cookie attributes.

Do I have to use a new web.xml schema for Servlet 6.0?
Yes. Applications using a deployment descriptor must use the updated schema location: https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd.

What happens to the deprecated APIs that were removed?
They are completely removed from the jakarta.servlet package. This includes methods like HttpSessionContext and various deprecated methods on Cookie and HttpUtils. Your code will not compile if it references them.

Releases In Branch 6.0

VersionRelease date
6.0.012 May 2022
(4 years ago)
6.0.0-M105 Nov 2021
(4 years ago)