Here is my Eclipse-wide JRE definition clearly showing the servlet-api.jar has been added:
And here are the same old import errors that just never seem to be able to be resolved. Isn't Java awesome? Any chance someone has a simple, factual answer as to why this still doesn't work?
CodePudding user response:
Any chance someone has a simple, factual answer as to why this still doesn't work?
Because:
- You are building against the Tomcat 10.0.10 servlet-api JAR file.
- Tomcat 10.0.x implements version 5.0 of the JSP spec; see http://tomcat.apache.org/whichversion.html
- JSP 5.0 is Jakarta EE, not Java EE; see https://en.wikipedia.org/wiki/Jakarta_Servlet#History
- In Jakarta EE, the package names for the servlet classes have changed from
javax.servlet
tojakarta.servlet
.
And your code is trying to use the old package name.
Solutions:
- Change your webapp code to import from the new package, OR
- Roll back to a version of Tomcat that supports the older version of the JSP spec; i.e. Tomcat 9.0.x or earlier.