File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes pl. tell me diff. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "pl. tell me diff." Watch "pl. tell me diff." New topic

pl. tell me diff.

Kapil Keskar
Ranch Hand

Joined: Dec 04, 2001
Posts: 47
Can any body tell me the difference between RequestDispatcher.forward() & response.sendRedirect() ?
What is the diff. ?
I think it is the difference between request time & response time redirection. is it correct?
Or else tell me the right?
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
In the RequestDispatcher.forward method the returned content from the resourse forwarded to is returned as if it were from the orginally requested resource. Meaning it is invisible to the browser. The address in the address bar remains that of the orginally requested resourse.
In a redirect the browser is told to request a different resource and its address bar changes to reflect that.
you can tell the difference by looking at the methods. In the forward method it takes as its parameters the request and repsonse objects because new ones aren't created. In the redirect method the browser makes a new request so the original ones aren't needed.
hope that helps

I agree. Here's the link:
subject: pl. tell me diff.
It's not a secret anymore!