32

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

When running the project on its loading index.html it's OK, but when trying to navigate to another page it's showing the error:

The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory

Please provide me a solution to get rid of this.

Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
RAVITEJA SATYAVADA
  • 2,503
  • 23
  • 56
  • 88

4 Answers4

78

Get rid of any servletcontainer-specific libraries such as jsp-api.jar in your /WEB-INF/lib folder. This exception indicates that you've put servletcontainer-specific libraries of a container which supports only Servlet 2.4 / JSP 2.0 or older in there (the getJspApplicationContext() method was introduced in Servlet 2.5 / JSP 2.1). This is a major mistake. Those libraries don't belong in the webapp's classpath.

Perhaps you did this to overcome project compilation errors, which is indeed a pretty common beginner's mistake. This should have been solved differently, you should refer the target runtime in your project, not copy some libraries of an arbitrary servletcontainer make/version into your project. It would make your project incompatible with servletcontainers of a different make and/or version.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
6

if you have a maven project try to add the following dependency

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
Giovanni Perea
  • 328
  • 3
  • 5
0

You need to reference a server runtime in your project.

In Eclipse:

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

That should do it!

Note: See this Stack Overflow post for more details on this problem

Community
  • 1
  • 1
Brad Parks
  • 66,836
  • 64
  • 257
  • 336
0

I had similar error when working with an open source project using eclipse, the issue was with my tomcat version. I was using tomcat version 6. I had to setup a server using tomcat version 8 to resolve the issue.

this link was helpful Unable to compile class for JSP

Sage Hassan
  • 31
  • 2
  • 8