-1

I'm running a Struts project (built in other machine) in NetBeans 8.0.2. I'm not using Maven.

Here's the trace:

      org.apache.jasper.JasperException: Unable to compile class for JSP: 

     An error occurred at line: [43] in the generated java file: [/home/sys6002/.netbeans/8.0.2/apache-tomcat-8.0.15.0_base/work/Catalina/localhost/PublisherTruepush/org/apache/jsp/home_005fpage_jsp.java]
     The method getDispatcherType() is undefined for the type HttpServletRequest
              Stacktrace:
        org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:199)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:450)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88

What can I do to solve this?

The code in /jsp/home_005fpage_jsp.java] at Line 43

final java.lang.String _jspx_method = request.getMethod();
if (!"GET".equals(_jspx_method) && !"POST".equals(_jspx_method) && !"HEAD".equals(_jspx_method) && !javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "JSPs only permit GET POST or HEAD");
return;
}
Roman C
  • 49,761
  • 33
  • 66
  • 176
Anil Kumar
  • 2,521
  • 7
  • 23
  • 40

1 Answers1

1

ServletRequest.getDispatcherType() was defined in Servlet 3.0 API.

The error indicates that you are either running the application with an older version of the Servlet API or that your application includes an servlet jar which is imcompatible with your runtime.

Since you are running Tomcat 8.0 I would check if your app includes jar files which contain an older servlet version.

wero
  • 32,544
  • 3
  • 59
  • 84
  • I'm using tomcat 8.0.15.0. It uses Servlet 3.1, JSP 2.3, EL 3.0, WebSocket 1.1 – Anil Kumar Jul 28 '15 at 06:24
  • Take a look at this post: https://stackoverflow.com/questions/17388175/how-to-know-which-servlet-and-jsp-version-am-i-using You can start with trying Kannas solution to print out the version in a JSP page. – wero Jul 28 '15 at 06:27
  • Then take a look at file `/home/sys6002/.netbeans/8.0.2/apache-tomcat-8.0.15.0_base/work/Catalina/localhost/PublisherTruepush/org/apache/jsp/home_005fpage_jsp.java` and post the lines around the offending line 43. – wero Jul 28 '15 at 06:29
  • I appended at end of question. Please see – Anil Kumar Jul 28 '15 at 06:33