[Solved] IDEA: JSP Could Not Use session Build-in Object

Problem description

Cause

since the author uses Tomcat 10, the servlet dependency used is Jakarta Servlet. For details, see building a servlet using Tomcat 10. An error is reported: class XXX is not a servlet. The error is because the servlet API package is not imported.

Solution:

Import servlet API dependencies.

<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  <version>4.0.1</version>
</dependency>

Similar Posts: