my dog learned polymorphism
The moose likes Servlets and the fly likes req.sendRedirect and Servlet.RequestDispatcher diferences Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "req.sendRedirect and Servlet.RequestDispatcher diferences" Watch "req.sendRedirect and Servlet.RequestDispatcher diferences" New topic

req.sendRedirect and Servlet.RequestDispatcher diferences

Partha Athreya

Joined: Jun 04, 2002
Posts: 4
Hi all..
can anyone plz., let me what exactly is the difference between request.sendRedirect and Servlet.RequestDispatcher methods..
thnx and Regards,
Partha Athreya

Partha Athreya
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

if you want to know the exact difference you'd have to look at the servlet API, but a search of this forum would be a good place to start.
You'd find threads like
srinath karkhani

Joined: Jun 19, 2002
Posts: 14
res.sendRedirect- this is the method which takes the absolute url and when this is executed it adds to the header the url and sends back to the browser client and it wud be treated as a new req then on i.e it makes a extra round of travelling back to the client when its executed.
RequestDispatcher.forward- this method takes the relative url and it just forwards the control to the specified relative url without again goin back to the client browser.
hope this helps if not im sorry
subject: req.sendRedirect and Servlet.RequestDispatcher diferences
It's not a secret anymore!