This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSP and the fly likes SendRidirect vs RequestDispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "SendRidirect vs RequestDispatcher" Watch "SendRidirect vs RequestDispatcher" New topic
Author

SendRidirect vs RequestDispatcher

Sandipan Mukherjee
Greenhorn

Joined: Dec 07, 2006
Posts: 8
Tell me the difference between response.sendRedirect and requestDispatcher.forward with respect to session?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

With respect to session, there is little difference between the two.

In general, they are very different.
requestDispatcher.forward takes place on the server, within one request cycle.
The client (browser) has no idea that this has taken place.

response.sendRedirect works by sending a 302 header (along with a Location header), suggesting that the browser make a brand new request.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

The client (browser) has no idea that this has taken place.


you can notice, in browser URL bar, URL will not change while you are doing forward but if you do redirect you can see that changing.


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SendRidirect vs RequestDispatcher