Wednesday, April 27, 2011

Difference between response.sendRedirect() and requestDispatcher.forward()

sendRedirect() and forward() are basically used to pass the request to another servlet for further processing.

sendRedirect() is basically is used when there request is to be sent to the servlet which is uploaded on another server. When the sendRedirect() is called, the servlet passes the request back to client and so that the client would call another servlet whose path is mentioned in the ().

forward() is used when the request is to be sent to the servlet which is present on the same server. When the forward() is called, the servlet passes the control to another servlet directly, without requesting the client again to call another servlet.

Thus, forward is pretty fast in execution but it has the boundary of the server container.  

No comments:

Post a Comment

PROFILE

My photo
India
Design Engineer ( IFM Engineering Private Limited )

Followers