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


rajanidhi rajasekeran

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

Joined: Feb 05, 2001
Posts: 17271

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

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: 1849

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,it is totally new request.

Krishna Srinivasan
OCAJP 7/8 Exam, 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
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: RequestDispatcher
jQuery in Action, 3rd edition