Difference between request.getRequestDispatcher() and ServletConfig.getRequestD

from:http://www.jguru.com/forums/view.jsp?EID=468507
Difference between request.getRequestDispatcher() and ServletConfig.getRequestDispatcher()


Hi

What is the Difference between a RequestDispatcher object obtained from The Request Object and RequestDispatcher object obtained from ServletContext . If at all there is a difference? i.e



request.getRequestDispatcher("url").forward(request,response);

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


There's no difference. They both return the same object.
getServletConfig().getServletContext().getRequestDispatcher() allows you to dispatch requests if you don't have access to the HttpServletRequest object, for example if you're in a method you've written which doesn't take the HttpServletRequest object as a parameter.




Re: Re: Differnce between request.getRequestDispatcher() and ServletConfig.getRequestDispatcher()
Topic: Servlets
Raji Chawla, Aug 5, 2001

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)

Cheers !!! Raji

你可能感兴趣的:(jsp,Access)