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.
1. Add Target Server Runtime. In this solution, you can add desired server runtime into your application as a project facet. As runtime servers have already servlet runtime dependencies, they get included in your project and hence the error is gone.
An abstract class that simplifies writing HTTP servlets. It extends the GenericServlet base class and provides an framework for handling the HTTP protocol. Because it is an abstract class, servlet writers must subclass it and override at least one method.
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.
jakarta.*
namespace with the latest Servlet & JSP specs.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.
jakarta.
namespace along with Tomcat 10.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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With