aspose file tools
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "RequestDispatcher" Watch "RequestDispatcher" New topic


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?
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.
rocket mass heater kickstarter
subject: RequestDispatcher