This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes Difference between getRequestDispatcher() from ServletContext and HttpServletRequest Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Difference between getRequestDispatcher() from ServletContext and HttpServletRequest" Watch "Difference between getRequestDispatcher() from ServletContext and HttpServletRequest" New topic
Author

Difference between getRequestDispatcher() from ServletContext and HttpServletRequest

Pranav Pal
Ranch Hand

Joined: Nov 04, 2007
Posts: 74
What is the difference between RequestDispatcher object got from following two calls:
(1) getServletContext().getRequestDispatcher()
(2) request.getRequestDispatcher()

Thanks..


Hakuna Matata!
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The difference is stated right in the API.
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#getRequestDispatcher(java.lang.String)
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html#getRequestDispatcher(java.lang.String)


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Difference between getRequestDispatcher() from ServletContext and HttpServletRequest