• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SendRidirect vs RequestDispatcher

 
Sandipan Mukherjee
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tell me the difference between response.sendRedirect and requestDispatcher.forward with respect to session?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic