upgrade servlet 4.0.1 to servlet 5.0
Asked Answered
T

2

5

I am upgrading servlet 4.0.1 to servlet 5.0. I was using below maven dependency for servlet 4.0.1

<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>4.0.1</version>
        <scope>provided</scope>
</dependency> 

When I am upgrading to servlet 5.0 then I see that There is a new term 'Jakarta' and servlet5 comes with Jakarta API with below maven dependency.

<dependency>
  <groupId>jakarta.servlet</groupId>
  <artifactId>jakarta.servlet-api</artifactId>
  <version>5.0.0</version>
</dependency>

So, there are below questions I tried to search on the internet but couldn't find

  1. Please explain about this new term Jakarta like how does this come into the picture?
  2. is this the only way to use Jakarta APIs to upgrade servlet 5.0. can we use old 'javax.servlet-api' ?
  3. I see, Jakarta was also there in the 4.0 version but we were not using it. does it not having any dependency with servlet 4. ? https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api
  4. what are the other things need to be required to upgrade servlet 4.0 to servlet 5.0?

Please also suggest any docs for reference if any

Tropism answered 9/8, 2021 at 5:22 Comment(3)
What capabilities specifically are you wanting from Servlet 5?Tour
The main reason for upgrading to servlet 5.0 is Jetty11. because this is Jetty11's prerequisite.Tropism
@AshishGoyanka then you probably just need to change the servlet specification version in your deployment descriptors...Leila
L
10

Servlet spec

You said:

I am upgrading servlet 4.0.1 to servlet 5.0.

No, that is not actually an « upgrade ».

There is no significant change in the Servlet spec between 4.0 and 5.0, other than moving from javax.* to jakarta.* package naming.

This change in namespace is one phase in the transition of Oracle Corp transferring responsibility for Java EE technologies to the Eclipse Foundation, becoming Jakarta EE.

You will not benefit from any new features or improvements by moving to Servlet 5 from Servlet 4.

In contrast, Jakarta Servlet 6 does bring signifiant changes and improvements.

Jetty

You commented:

The main reason for upgrading to servlet 5.0 is Jetty11. because this is Jetty11's prerequisite.

Jetty 10 is the same as Jetty 11, but for the change in package name from javax.* to jakarta.*. The two versions are developed in parallel. There are no better features or improvements to be found in Jetty 11 over Jetty 10.

(By the way, ditto for Apache Tomcat 9.x and Tomcat 10.0, parallel versions for package naming change.)

👉 If you want to be conservative for now, stick with Jetty 10 and the javax.* package naming. If you want to prepare for the future, use Jetty 11 and jakarta.* package naming.


There are many articles, presentations, and interviews about the transition with Oracle Corp handing control of Java EE to the Eclipse Foundation, and the accompanying name change to Jakarta EE. You really should do some basic industry research on this Oracle-to-Jakarta topic, to understand the changes. Start with Wikipedia.

Longship answered 9/8, 2021 at 8:14 Comment(0)
A
2
  1. Please explain about this new term Jakarta like how does this come into the picture?

Oracle maintained Java EE, on September 2017 Oracle Announced that Java EE will be submitted to Eclipse Foundation. "Java" is a trademark owned by Oracle so "Java EE" was renamed to "Jakarta EE".

  1. is this the only way to use Jakarta APIs to upgrade servlet 5.0. can we use old 'javax.servlet-api' ?
  2. I see, Jakarta was also there in the 4.0 version but we were not using it. does it not having any dependency with servlet 4. ? https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api

The first release of Jakarta EE 8 includes Servlet 4.x and it is compatible with Java EE 8. Java EE 8 and Jakarta EE 8 use javax.* namespace.

It doesn't matter which one you are using both will work with each other.

what are the other things need to be required to upgrade servlet 4.0 to servlet 5.0?

To upgrade to Servlet 5.0, you must use Jakarta EE 9. From Jakarta EE 9 the namespace is changed from javax.* to jakarta.* so you must alter all javax.* packages imports to jakarta.* packages.

Also, if you are using any other libraries, you must use a compatible version.

The maven dependency for Jakarta EE Web API is the following.

<dependency>
    <groupId>jakarta.platform</groupId>
    <artifactId>jakarta.jakartaee-web-api</artifactId>
    <version>9.1.0</version>
    <scope>provided</scope>
</dependency>

REF: GitHub Template for Jakarta EE 9 Web

Ambrosine answered 9/8, 2021 at 6:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.