GetJspApplicationContext (ServletContext) undefined method for type JspFactory

I am working on a JSP project that uses Apache Tomcat 7.

When you start the project when loading index.html, this is normal, but when you try to go to another page, it shows an error:

GetJspApplicationContext (ServletContext) undefined method for type JspFactory

Please provide me a solution to get rid of this.

+26
jsp tomcat
Aug 15 '11 at 11:12
source share
3 answers

Get rid of any servlet specific libraries like jsp-api.jar in your /WEB-INF/lib folder. This exception indicates that you have installed servlet getJspApplicationContext() specific libraries that only support Servlet 2.4 / JSP 2.0 or older (the getJspApplicationContext() method was introduced in Servlet 2.5 / JSP 2.1). This is a serious mistake. These libraries do not belong to the webapp class path.

You may have done this to overcome project compilation errors, which is indeed a fairly common beginner error. This had to be solved in different ways, you should refer to the target runtime in your project, and not copy some libraries of the arbitrary servletcontainer make / version file to your project. This will make your project incompatible with the servletcontainers of another make and / or version.

See also:

  • How to import javax.servlet API into an Eclipse project?
+69
Aug 15 '11 at 12:22
source share
— -

if you have a maven project try adding the following dependency

  <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency> 
+5
Jul 27 '15 at 21:06
source share

You need to reference the server runtime in your project.

In Eclipse:

  • Select Project | Properties | Java Build Path | Libraries Tab
  • Click Add Library | Server Runtime | Apache Tomcat 7
  • Click OK.
  • Clean the project and build it again ("Project | Clear", then "Project | Create All")

That should do it!

Note. See this post for more on this issue.

0
Feb 13 '13 at 16:25
source share



All Articles