Wish to have some nice time? Check out what I'm reading online!

Difference between ServletRequest.getRequestDispatcher and ServletContext.getRequestDispatcher

May 6th, 2008
  • request.getRequestDispatcher(“url”) means the dispatch is relative to the current HTTP request.
    Example code: RequestDispatcher reqDispObj = request.getRequestDispatcher("/home.jsp");
  • getServletContext().getRequestDispatcher(“url”) means the dispatch is relative to the root of the ServletContext.
    Example code:RequestDispatcher reqDispObj = getServletContext().getRequestDispatcher("/ContextRoot/home.jsp");





hidden and gravatar enabled.