Leaderboard1

Leaderboard2

Wednesday, December 5, 2012

java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getServletContext () Ljavax / servlet / ServletContext;


ServletRequest the getServletContext method added Servlet3.0, this can look at the official documentation
And Tomcat6 only support to Servlet2.5 see its official documents can know there was replaced Tomcat7 use J2EE6 then
Older version you need to use the request to get the HttpSession get through to Servlet own to get ServletConfig ServletContext.

For Tomcat6 use:
request.getServletContext().getContextPath() instead of request.getContextPath()

1 comment:

  1. For Tomcat 6 use this:
    ServletContext context = request.getSession().getServletContext();

    Not what is mentioned above.

    ReplyDelete