File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestDispatcher

 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 405
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic