Hello,
What is the basic difference between RequestDispatcher and sendRedirect method ?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vikas MishraPosted Nov 21, 2011, 5:48 PM
Prabhu RajaPosted Oct 14, 2011, 2:09 AM
For more reference : Click Here
Satyapriya NayakPosted Oct 13, 2011, 2:46 PM
response.sendRedirect():
This is complete new request to browser.
Request is not maintained so data stored in request object not available to redirect page.
You have to store data in session to get in the redirect jsp.
You can pass data like response.sendRedirect("/abc.jsp?name=satya). Then in the abc.jsp you have to get name using request.getParameter("name");
This is fresh call to server.
For example .. you forwarded from /login to login.jsp
in the browser you can see /login.jsp....
requestDispatcher.forward() : This not new request. Just transfer the content to forwarded jsp.
You can store data in request and able to get in redirect jsp.
For example .. you forwarded from /login to login.jsp
in the browser you can see /login ....
Disadvantage - browser refresh call to /loginj again. may be duplicate data submit.
Also refer the below link
http://www.roseindia.net/help/java/s/forward-vs-redirect.shtml