What's the difference between forward and sendRedirect?

Questions by sowbakian

Showing Answers 1 - 11 of 11 Answers

dipali

  • Oct 10th, 2005
 

forward will just forward the request to next page where as sendRedirect will first come back to the page where its been generated and the redirect to next page

chaitanya

  • Oct 27th, 2005
 

RequestDispatcher.forward() and HttpServletResponse.sendRedirect() are the two methods available for URL redirecting to another jsp or servlet.

sendRedirect() is more flexible than forward() because with sendRedirect() you can connect to any URL outside the webapplication whereas forward() will work only within the web application.

sendRedirect() is slower than forward()

sendRedirect() is on the client side whereas forward() is on the server side.

Gopal

  • Nov 8th, 2005
 

In both cases the output will be same. In case of forward single request process to resource, In case of redirect multiple requests processed and we can forward request to resource wihin  same web application only.We can redirect request to resource within same web application or other web applicatio also.

  Was this answer useful?  Yes

RequestDispatcher.forward() is completely handled on serverside while HttpServletResponse.sendRedirect() sends a redirect message to the browser.

RequestDispatcher.forward() is transparent to the browser while HttpServletResponse.sendRedirect() is not.

  Was this answer useful?  Yes

Rahul

  • Nov 18th, 2005
 

In case of forward, web server shows the content of forwarded page without leting the user client knowing about the source.where as in redirect a new url is returned back to user client, and then user client makes a new request to new url to fetch the content.

  Was this answer useful?  Yes

forward1 using forward we can redirect the pages with in the same context of web server2 it is faster than send redirect.sendRedirect1 using this we can redirect any url..2 it is very slow because when we redirect the page that url first sent by the server to client .when the client recive the response means( url) again send to the client..

  Was this answer useful?  Yes

Pankaj Jaiswal

  • Apr 13th, 2006
 

there are a lot of difference between RequestDispatcher.forward() and HttpServletResponse.sendRedirect() ==>1) The forward() works within your application while sendRedirect() can also work outside of the application.2) SendRedirect() is slower then the forward().3) if you use sendRedirect() then no request-response will be available to you on forwarded page while it can be available through forward().3) if we use sendRedirect(), the url of the browser has been changed while it has not been changed by forward()4) sendRedirect() is on the client side while forward() is on the server side.

  Was this answer useful?  Yes

duryodhan

  • Aug 6th, 2007
 

Forward works only on server side means control will be on server but send redirect send the redirected response to the browser.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.