Hi,
What is the difference between the following?
HttpServletResponse.sendRedirect(String url)
and
RequestDespatcher.forward(ServletRequest req,ServletResponse res)
Are the both methods doing the same funtionaltiy?
Thanks in advance
Bye
Rama
-
sendRedirect() vs forward() (4 messages)
- Posted by: Ramasubramanian Balasubramanian
- Posted on: April 27 2001 07:50 EDT
Threaded Messages (4)
- sendRedirect() vs forward() by e d on April 27 2001 08:50 EDT
- sendRedirect() vs forward() by Andy Nguyen on April 27 2001 10:26 EDT
- sendRedirect() vs forward() by Ramasubramanian Balasubramanian on May 09 2001 06:56 EDT
- sendRedirect() vs forward() by sudheer babu on April 07 2010 04:00 EDT
-
sendRedirect() vs forward()[ Go to top ]
- Posted by: e d
- Posted on: April 27 2001 08:50 EDT
- in response to Ramasubramanian Balasubramanian
-
sendRedirect() vs forward()[ Go to top ]
- Posted by: Andy Nguyen
- Posted on: April 27 2001 10:26 EDT
- in response to Ramasubramanian Balasubramanian
sendRedirect() sends a redirect response back to the client's browser. The browser will normally interpret this response by initiating a new request to the redirect URL given in the response.
forward() does not involve the client's browser. It just takes browser's current request, and hands it off to another servlet/jsp to handle. The client doesn't know that they're request is being handled by a different servlet/jsp than they originally called.
There are different situations where you want to use one or the other. For example, if you want to hide the fact that you're handling the browser request with multiple servlets/jsp, and all of the servlets/jsp are in the same web application, use forward() or include(). If you want the browser to initiate a new request to a different servlet/jsp, or if the servlet/jsp you want to forward to is not in the same web application, use sendRedirect().
Andy -
sendRedirect() vs forward()[ Go to top ]
- Posted by: Ramasubramanian Balasubramanian
- Posted on: May 09 2001 06:56 EDT
- in response to Andy Nguyen
Hi Andy Nguyen,
Thanks for clearcut explanation.
Bye,
Rama. -
sendRedirect() vs forward()[ Go to top ]
- Posted by: sudheer babu
- Posted on: April 07 2010 04:00 EDT
- in response to Andy Nguyen
in the case of the sendRedirect(String) technique it will call on the response object,but in the case of the RequestDispatcher(String) it will work on the request object, here we having 2 tech.. i.e forward(request,response) and includ(request, response), i think this is basic difference b/t the both tech..... the final goal of 2 tech... are the same to bypass the request from one jsp page to another.
thank u