I am just trying to learn some JSP but I am getting that error repeatedly. I've tried everything on the internet and nothing happened. I am using the Tomcat v10 and JDK15.0.2. This error occurs when I create a new JSP file.

- 99
- 2
- 7
-
1Does this answer your question? [Servlet 5.0 JAR throws compile error on javax.servlet.\* but Servlet 4.0 JAR does not](https://stackoverflow.com/questions/64387472/servlet-5-0-jar-throws-compile-error-on-javax-servlet-but-servlet-4-0-jar-does) – Piotr P. Karwasz Feb 28 '21 at 08:19
2 Answers
Java EE ⇝ Jakarta EE
Read the front page of downloading documentation for Apache Tomcat 10. To quote:
Users of Tomcat 10 onwards should be aware that, as a result of the move from Java EE to Jakarta EE as part of the transfer of Java EE to the Eclipse Foundation, the primary package for all implemented APIs has changed from javax.* to jakarta.*. This will almost certainly require code changes to enable applications to migrate from Tomcat 9 and earlier to Tomcat 10 and later.
And read the first page of the main documentation for Apache Tomcat 10. To quote:
Apache Tomcat version 10.0 implements the Servlet 5.0 and JavaServer Pages 3.0 specifications from Jakarta EE …
As part of Oracle turning over responsibility for what was known as Java EE (Enterprise Edition) to the Eclipse Foundation, the package names in Jakarta EE are changing from javax.*
to jakarta.*
. You can read about this on the Tomcat page, Which version? — Apache Tomcat Versions, and on the internet.
- Tomcat 10 is for people moving forward to Jakarta EE versions 9 and later, using the
jakarta.*
namespace with the latest Servlet & JSP specs. - Tomcat 9 is for people sticking with the
javax.*
namespace using the popular Servlet 4 spec and related APIs.
If you want to use the latest APIs, change your import
statements to use jakarta.
rather than javax.
. Or switch out your Tomcat 10 for Tomcat 9 to use the older javax.
namespace.
- If you are learning and experimenting, I suggest using the
jakarta.
namespace along with Tomcat 10. - If you are using important libraries or tools that are not yet updated to the
jakarta.
namespace, stick with the older APIs and Tomcat 9.
There has been talk of tools to help by automating some of this namespace switch. But I do not know of the state of affairs there.

- 303,325
- 100
- 852
- 1,154
You need an update from https://download.eclipse.org/releases/2021-03/ . Support for Apache Tomcat 10 and Jakarta EE JSPs is extremely new.
I suppose you could also just use Tomcat 9.

- 19,089
- 4
- 34
- 43