• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RequestDispatcher

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic