• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can anybody tell me the difference between sendRedirect & RequestDispatcher object?

 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all
Can anybody tell me the difference between sendRedirect & RequestDispatcher object? Please make me understand by using a suitable example.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Redirect - Makes the browser do another request on behalf of you.

RequestDispatcher - The server does the redirect.

If you see the difference, with your redirect, it's all together like making a new request which means, your request param values that you had before the redirect happened is lost and all together a new one is generated once the redirect happens. Hope you get the difference between them.
 
Devi Sri
Ranch Hand
Posts: 115
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) sendRedirect --> The server will send to the browser the new url. The browser will follow this url. You can see the change of URL in the browser address bar. Means , the client handles the redirection.

2) RequestDispatcher --> The server will transfer the request to another web component on the server side. There will not be change in url in the browser(client side). Means, the server handles the redirection.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic