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 RequestDispatcher 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 "RequestDispatcher" Watch "RequestDispatcher" New topic
Author

RequestDispatcher

rajanidhi rajasekeran
Greenhorn

Joined: Aug 28, 2003
Posts: 4
Hai all,
What is the difference b/w RequestDispatcher.Forward() and Response.redirect().I am totally confused with this, plz help.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

I think redirect requires another round trip between the client and server, and forward does not.
that is one difference, there are moer, but I can't remember them offhand.
Good Luck
mar


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1844

forwared() will process in server side.client don't know what's happening inside.
but senredirect will return the request to client and redirect to new request.so,it is totally new request.


Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 400+ OCPJP Mock Questions
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
When forwarding to an HTML page containing relative URLs included, RequestDispatcher's forward() does not notify the client about the directory from which the page is served, hence the links may be broken. Instead, use HttpServletResponse's sendRedirect() as the servlet container must convert the relative URL to an absolute URL before sending the response to the client.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
 
jQuery in Action, 2nd edition
 
subject: RequestDispatcher