Series: Subject: Topic:
Question: 154 of 177

What is difference between sendRedirect() and forward()..? Which one is faster then other and which works on server?

Asked by: Interview Candidate | Asked on: Sep 2nd, 2005
Showing Answers 1 - 10 of 10 Answers

Answered On : Jun 11th, 2005

When you invoke a forward request, the request is sent to another resource on the server, without the client being informed that a different resource is going to process the request. This process occurs completely with in the web container. When a sendRedirtect method is invoked, it causes the web container to return to the browser indicating that a new URL should be requested. Because the browser issues a completely new request any object that are stored as request attributes before the redirect occurs will be lost. This extra round trip a redirect is slower than forward.

Yes  2 Users have rated as useful.
Login to rate this answer.
J. P. Naidu

Answered On : Jul 27th, 2005

SendRedirect method is in Request Object where as the forward is in the RequestDespatcher Object.  In forward, request and respone objects are available to the forwarded page where it is not possible in sendRedirect

Login to rate this answer.
J. P. Naidu

Answered On : Jul 28th, 2005

Quote: sendRedirect method is in Request Object  Correction of the above: it is in response object

Login to rate this answer.

Answered On : Sep 2nd, 2005

"sendRedirect" is a Response Object, but not a Request Object. Please.. Don't mis guide...

Login to rate this answer.

Answered On : Nov 9th, 2005

View all answers by BhupenderGiri

Actually when we use sendRedirect method then u r changing or transfering the request to new URL.Mean new URL is formed .In case of Forward method of RequestDispatcher your context is not changed means ur URL object remains same.Since URL is same so forward() method is faster than sendRedirect one.Also in case of sendRedirect() method when u reach to new page the request/value at previous one is lost.Also forward() method is handled from server to server but sendRedirect() method is not.

Login to rate this answer.

Answered On : Apr 25th, 2007

View all answers by rameshvdnv

The difference between sendRedirect() and forward() is nothing but it will redirect to a resource that is available in a webcontainer or in another webcontainer and that resource will be executed from the browser.    Suppose if we use forward()the requestdispatcher forwards the request to the specified jsp(servlet)and the called jsp(servlet)result(o/p)will be sent to the browser.

Login to rate this answer.

Answered On : Jul 11th, 2007

In forword() the request is sent to another page with in the webapplication only.where as response.sendredirect() will sent the respone to another web application.

Login to rate this answer.
Deepak Tewari

Answered On : Oct 23rd, 2007

In simple words we sayresponse.sendRedirect takes full round trip ie goes to the browser and comes back to the server where as forward is server to server transferresponse.sendRedirect makes a new request so all previous request parameters are lost and in order to persist the data you need to send through query string  where as in forward the old request is forwarded so all old request data persist

Login to rate this answer.

Answered On : Jun 15th, 2008

View all answers by aditya25_abes

forward() can be used only within same application and response is send by the forwarded servlet.while send Redirect can also be be used outside the the application (requested servlet must be deploy on the the same webserver)and one more thing the request is send by browser to the requested servlet not by a servlet.both works on servers

Login to rate this answer.

Answered On : Apr 8th, 2010

View all answers by paramsethi

In addition to all of the above answers, one point of difference that was missed is,The forward method takes the relative URL to the servlet, where as sendRedirect method requires the full URL of the destination.

Login to rate this answer.

Give your answer:

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

Related Open Questions



twitter fb Linkedin GPlus RSS


Interview Question

 Ask Interview Question?


Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.