Hello, 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?
Joined: May 10, 2001
Kapil 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