This is what I got on the browser screen when I try to run the JSP file.
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
And the jasper exception is thrown on the Tomcat window when I ran it.
Best Answer
That method was introduced in JSP 2.1. There are 3 causes for this problem:
You're using an too old version of the JSP container (you need for example at least Tomcat 6.0).
You've declared the wrong Servlet version in
web.xml
. JSP 2.1 goes hand in hand with Servlet 2.5, so yourweb.xml
should at least be declared as per the Servlet 2.5 spec (you still need a Servlet 2.5 / JSP 2.1 capable servletcontainer for that).You've duplicated older versioned appserver-specific libraries into webapp's
/WEB-INF/lib
, likeservlet-api.jar
,jsp-api.jar
and so on. You should never do that. It will only result in classloading collisions. Get rid of them in your webproject and leave/untouch them there in the appserver.