5.0.0

Latest release in branch 5.0
Released 5 years ago (September 07, 2020)

Software Servlet/Jakarta
Branch 5.0
First official release version 5.0.0
First official release date 5 years ago (September 07, 2020)
Platform Jakarta EE 9
Source code https://github.com/jakartaee/servlet/tree/5.0.0-RELEASE
Documentation https://javadoc.io/doc/jakarta.servlet/jakarta.servlet-api/5.0.0/index.html
Download https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api/5.0.0
Servlet/Jakarta 5.0 Releases View full list

What Is New in Servlet 5.0

Servlet 5.0 is a major update that aligns the specification with the Jakarta EE namespace, moving from Java EE to the Eclipse Foundation. The core functionality remains stable, but the package names have changed.

Category Key Changes
Namespace Change All APIs moved from javax.servlet to jakarta.servlet
New Features Added the HttpSessionIdListener interface for tracking session ID changes
API Updates Introduction of new default methods in existing interfaces
Requirements Now requires Java SE 11 or later

Why did the package name change from javax to jakarta?

The package change is the most significant aspect of Servlet 5.0. This isn't just a rename; it represents the official transfer of the specification from Oracle's Java EE to the Eclipse Foundation's Jakarta EE platform.

In practice, this means you'll need to update all your import statements in servlets, filters, and listeners. Your build configuration (Maven, Gradle) must also pull dependencies from the new Jakarta artifacts instead of the old Java EE ones.

What new listener was added for tracking session activity?

Servlet 5.0 introduces the HttpSessionIdListener interface. This allows you to receive notifications when the ID of an existing HTTP session is changed, typically for security reasons like session fixation protection.

You implement it by defining the sessionIdChanged method. This gives you a hook to manage application state or logging when a session ID is renewed, which was previously more difficult to track directly.

public class MySessionIdListener implements HttpSessionIdListener {
    @Override
    public void sessionIdChanged(HttpSessionEvent event, String oldSessionId) {
        // Handle the session ID change
    }
}

How does the Java 11 requirement affect my deployment?

Servlet 5.0 mandates Java SE 11 as the minimum runtime. This allows the API to leverage newer language features and modules introduced in later Java versions.

For developers, this means you must upgrade your JDK/JRE and ensure your application server supports Java 11. This is a good time to review your code for any deprecated APIs that were removed in Java 9+.

FAQ

Is Servlet 5.0 a drop-in replacement for Servlet 4.0?
No. The package name change from javax.servlet to jakarta.servlet means you must update all import statements in your source code and reconfigure your project dependencies. The API behavior is consistent, but the namespace is different.

What is the purpose of the new HttpSessionIdListener?
It provides a callback for when a session's ID is changed, which is a common security measure to prevent session fixation attacks. Your application can use it to update internal mappings or audit logs that are tied to the session ID.

Do I have to use Java modules with Servlet 5.0?
No, the specification does not force you to use the Java Platform Module System (JPMS). You can still run your applications on the classpath. However, the specification and compatible containers are built to support a modular runtime.

Will my old servlet-based applications still work?
Yes, but they will need to be recompiled with the new jakarta.servlet imports. The core semantics of the servlet API, like the request/response cycle and lifecycle, remain unchanged and fully compatible.

Which application servers support Servlet 5.0?
You will need a server that implements the Jakarta EE 9 platform or later, such as Apache Tomcat 10+, Eclipse Jetty 11+, or Jakarta EE compatible commercial servers. Tomcat 9 and earlier support Servlet 4.0 and will not work.

Releases In Branch 5.0

Version Release date
5.0.0 5 years ago
(September 07, 2020)
5.0.0-M2 5 years ago
(July 14, 2020)
5.0.0-M1 6 years ago
(January 10, 2020)