What Is New in JSP 3.1
JSP 3.1 is a maintenance release focused on aligning with the Jakarta EE 9 platform, which involves the critical namespace change from javax.servlet.jsp to jakarta.servlet.jsp. This update ensures compatibility and sets the foundation for future development within the Jakarta EE ecosystem.
| Category | Description |
|---|---|
| Namespace Change | All API packages moved from javax.* to jakarta.*. |
| Specification Alignment | Updated to work with Jakarta Servlet 5.0 and other Jakarta EE 9 specifications. |
| Minimum JDK Version | Requires Java SE 8 or later. |
What are the key changes in JSP 3.1?
The single most significant change is the package namespace update. This isn't just a simple find-and-replace; it's a fundamental shift that impacts your application's dependencies, build configuration, and deployment descriptors.
Package Namespace Update
Every package previously under javax.servlet.jsp is now under jakarta.servlet.jsp. This includes core tags, EL, and the JSP API itself. In practice, this means you'll need to update your imports, TLD files, and any XML configuration that references the old namespace.
<%-- Old import --%>
<%@ page import="javax.servlet.jsp.JspWriter" %>
<%-- New import --%>
<%@ page import="jakarta.servlet.jsp.JspWriter" %>
Jakarta EE 9 Platform Alignment
JSP 3.1 is part of the Jakarta EE 9 release train. This matters because all your other Jakarta EE components, like Servlet 5.0 and Expression Language 4.0, will also be using the jakarta.* namespace. Your entire application stack needs to be consistent to avoid classloading conflicts.
How does JSP 3.1 affect my existing applications?
Migrating an existing application to JSP 3.1 requires a planned effort to update namespace references. The core functionality of writing JSP pages remains the same, but the underlying APIs have moved.
You'll need to modify your source code, update your web.xml to reference the new schema locations, and ensure all your libraries are compatible with the Jakarta EE 9 platform. This is a necessary step to stay on supported versions of the specification.
<!-- Old web.xml schema -->
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<!-- New web.xml schema for Jakarta EE 9 -->
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
version="5.0">
FAQ
Is JSP 3.1 a feature release?
No, it's primarily a maintenance release for the Jakarta EE 9 namespace change. The core JSP syntax and features are unchanged from the previous version.
Do I have to change all my JSP page code?
Your HTML and basic scriptlet code doesn't need to change. However, you must update any Java import statements and Tag Library Descriptor (TLD) references from javax.servlet.jsp to jakarta.servlet.jsp.
Can I run JSP 3.1 on Tomcat?
Yes, but you need Tomcat 10.0 or higher, as it is the first version to implement the Jakarta Servlet 5.0 and JSP 3.1 specifications using the jakarta.* namespace.
What happens if I mix javax and jakarta namespaces?
Your application will fail to compile or deploy. The classloader will treat javax.servlet.jsp.JspWriter and jakarta.servlet.jsp.JspWriter as completely different, incompatible classes.
Are there any new features for the Expression Language (EL)?
JSP 3.1 uses Expression Language 4.0, which is part of its own specification. The main change for EL 4.0 is also the package rename to jakarta.el.*.