Question subject: Difference between forward and sendRedirect
Posted: Fri Nov 07, 2008 12:50 pm
Joined: Wed Mar 28, 2007 7:31 pm Posts: 14 Has thanked: 0 time Have thanks: 0 time
Q: Difference between forward and sendRedirect?
A: 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 completly 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 completly 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.
Question subject: Re: Difference between forward and sendRedirect
Posted: Sat Jul 25, 2009 1:44 pm
Joined: Wed Apr 15, 2009 7:18 am Posts: 32 Has thanked: 0 time Have thanks: 0 time
forward runs on the server side while sendRedirect runs on the client as well as on the server side thats why the response generated by sendRedirect() is slow as compared to rd.forward().By using sendRedirect() you can forward the request to any web application either in the same server or to the another one.Incase of forward() the request has to be forwarded to the same web application.One more difference is that forward() method holds the previous request and response objects while using sendRedirect(),it will create fresh request and response objects