This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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
Author

RequestDispatcher

Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238

Hi,

I would like to know more about RequestDispatcher.When it is ,where, benefits of using it. How to invoke it. Why it needs to be used along with forward() method. Any ideas, suggestions, sample code, resources, links highly appreciated. Thanks in advance
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63208
    
  69

This is more appropriate to the servlets forum, so it's been moved.

The request dispatcher is the means by which resources are included into a request, or in which request are forwarded to other resources.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Javin Paul
Ranch Hand

Joined: Oct 15, 2010
Posts: 294



RequestDispatcher is an essential utility class which has two important methods include() and forward() , include () is used in case you would like to include response from some other servlet while forward() is used when you want to forward request to some other Servlet for further processing.

RequestDispatcher is retreived by calling either ServletRequest.getRequestDispatcher() method or the ServletContext.getRequestDispatcher() method.

its important to note the difference between two former looks for resource from current path while later looks for resource form absoluter path "/"


SQL Query Interview Question
Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238
>>>former looks for resource from current path while later looks for resource form absoluter path "/"

I have not understood above point. what you mean by current path and absoluter path. Can you please elaborate.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: RequestDispatcher
 
It's not a secret anymore!