6.1.0

Latest release in branch 6.1
Released 1 year ago (May 24, 2024)

Software Servlet/Jakarta
Branch 6.1
First official release version 6.1.0
First official release date 1 year ago (May 24, 2024)
Platform Jakarta EE 11
Source code https://github.com/jakartaee/servlet/tree/6.1.0-RELEASE
Documentation https://javadoc.io/doc/jakarta.servlet/jakarta.servlet-api/6.1.0/index.html
Download https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api/6.1.0
Servlet/Jakarta 6.1 Releases View full list

What Is New in Servlet 6.1

Jakarta Servlet 6.1 is a maintenance release focused on clarifications and minor feature additions. It builds directly on the major changes introduced in Servlet 6.0 without altering the core API.

Category Description
New Features Introduction of the HttpSessionIdListener interface.
Clarifications Refined text around context initialization parameters, response flushing, and URL patterns.
TCK Updates Enhancements to the Technology Compatibility Kit for improved implementation testing.

What new listener was added for session ID tracking?

The main API addition is the HttpSessionIdListener interface. This allows you to receive notifications when a session ID is changed, typically during a call to HttpServletRequest.changeSessionId().

In practice, this is crucial for security. After a user's authentication state changes, you often change the session ID to prevent session fixation attacks. This listener lets you track that event and update any internal mappings that were tied to the old session ID.

Example Implementation

public class MySessionIdListener implements HttpSessionIdListener {
    @Override
    public void sessionIdChanged(HttpSessionEvent event, String oldSessionId) {
        // Update security context or audit log
        System.out.println("Session ID changed from " + oldSessionId + " to " + event.getSession().getId());
    }
}

What clarifications were made to the specification text?

The 6.1 release includes numerous non-normative edits to improve readability and eliminate ambiguity. These don't change the API contract but make the intended behavior clearer for implementors and developers.

Key areas that received updates include the rules for context initialization parameters, the semantics of response stream flushing, and the matching of URL patterns. This matters because it reduces the chance of different Servlet containers having slightly different interpretations of the spec.

How does the TCK improve for this version?

The Technology Compatibility Kit (TCK) for Servlet 6.1 was enhanced with new tests. The TCK is the test suite used to verify that a Servlet container implementation is fully compliant with the specification.

These updates ensure that all implementations handle the new HttpSessionIdListener correctly and adhere to the clarified behaviors. For container vendors, passing the updated TCK is a requirement for certification.

FAQ

Is Servlet 6.1 a major upgrade from 6.0?
No, it's a maintenance release. The core API from 6.0 remains unchanged. The changes are primarily clarifications and the addition of one new listener interface.

When should I use the new HttpSessionIdListener?
Use it whenever your application logic needs to know that a session's ID has changed. The primary use case is updating security contexts or audit logs that track sessions by their ID after a call to changeSessionId().

Do I need to change my existing servlets to work with 6.1?
No. This release is fully backward compatible with Servlet 6.0. Your existing code will run without modification on a 6.1-compliant container.

What is the main benefit of the specification clarifications?
They reduce ambiguity, leading to more consistent behavior across different Servlet container implementations (like Tomcat, Jetty, etc.). This helps write more portable applications.

Where can I find the official list of changes?
The complete changelog is detailed in the Jakarta Servlet 6.1 Specification PDF (Appendix D).

Releases In Branch 6.1

Version Release date
6.1.0 1 year ago
(May 24, 2024)
6.1.0-M2 2 years ago
(February 27, 2024)
6.1.0-M1 2 years ago
(November 16, 2023)