dcsimg

What is the difference between a RequestDispatcher object obtained from the Request object and the RequestDispatcher object obtained from the ServletContext ?

Raji Chawla

 
request.getRequestDispatcher("url").forward(request,response);
and
getServletConfig().getServletContext().getRequestDispatcher("url").forward(request,response);

One : you can pass relative URL address when using request.getRequestdispather, and absolute URL address when using ServletConfig.getRequestDispatcher.

Two: All request details are not passed when using ServletConfig.getRequestDispatcher. May be it is the query string parameters for the current page that does not reach the page where request is forwarded. (don't remember exactly..surf it out)