Different between RequestDispatcher and sendRedirect

Different between RequestDispatcher and sendRedirect

Posted in : Servlet Posted on : November 30, 2010 at 6:16 PM Comments : [ 0 ]

This section contains the different between RequestDispatcher and sendRedirect.

Different between RequestDispatcher() and sendRedirect()

Both methods are used to forward request from one servlet to another. Difference between them are given below :

The RequestDispatcher.forward()  method acts on the server while response.sendRedirect() method acts on the web browser.

When you call requestDispatcher method, the servlet engine transfers control of this HTTP request internally from your current servlet or JSP to another servlet or JSP or static file.

The sendRedirect method always sends a header back to the client/browse which contains the resource(page/servlet) which you wanted to be redirected. The web browser uses this header to make another request.

But the major diff between the two is that forward just routes the request to the new resources which you specify in your forward call that means this route is made by the servlet engine at the server level only. No headers are sent to the browser.

Go to Topic «PreviousHomeNext»

Your Comment:

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image

Tutorial Topics