• Post Reply Bookmark Topic Watch Topic
  • New Topic

sendRedirect vs getRequestDispatcher

 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Suppose i want to call www.yahoo.com. Which method i should use : sendRedirect() or getRequestDispatcher() and why?

Thnx in advance
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sendRedirect does a CLIENT-side redirect, so the browser is instructed to fetch a different page instead of the one it requested.
requestDispatcher does a SERVER-side redirect or forward, so no network roundtrip is involved, but the new address needs to be accessible through the same servlet container.
So in your case you need to use sendRedirect, as the page is on a different server.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!