wood burning stoves 2.0*
The moose likes Servlets and the fly likes RequestDispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "RequestDispatcher" Watch "RequestDispatcher" New topic
Author

RequestDispatcher

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
When to use th servletContext and when to use request object?
Other than the URL Is there any diff between them?
getServletConfig().getServletContext().getRequestDispatcher("/servlet/ViewMiniPoll").forward(req,res);
RequestDispatcher rd = req.getRequestDispatcher("/anotherServlet");
rd.forward(req, res);
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
I believe the ServletRequest.getRequestDispatcher(java.lang.String) and the ServletContext.getRequestDispatcher(java.lang.String) cannot access resources outside of the current servlet context, but you can use the ServletContext.getContext(java.lang.String) to obtain RequestDispatcher for resources outside of the current context.
Craig
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RequestDispatcher
 
Similar Threads
servlet sendRedirect()
Problem with RequestDispatcher
question in sendRedirect()
Method call with Parameter
to do a forward in servelt