File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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: 17276

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 - iOS Apps
How to Ask Questions the Smart Way FAQ
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1850

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 agree. Here's the link:
subject: RequestDispatcher
It's not a secret anymore!