RequestDispatcher.forward() :
1) Forwards the request to some other servlet/jsp within the same application.
2) The URL in the browser does not change so the client does not get to know that the request is being sent to some other servlet. The process occurs completely within the web container
3) Request attributes are maintained
4) Faster, since everything is at the server side only
Response.sendRedirect()
1) Can forward request to a resource in some other application as well
2) The URL in the browser changes. So the web container returns to the browser indicating that the a new URL should be requested.
3) Since a new request object is created, any request attributes already stored will be destroyed.
4) Slower, since the round trip to client is involved
1) Forwards the request to some other servlet/jsp within the same application.
2) The URL in the browser does not change so the client does not get to know that the request is being sent to some other servlet. The process occurs completely within the web container
3) Request attributes are maintained
4) Faster, since everything is at the server side only
Response.sendRedirect()
1) Can forward request to a resource in some other application as well
2) The URL in the browser changes. So the web container returns to the browser indicating that the a new URL should be requested.
3) Since a new request object is created, any request attributes already stored will be destroyed.
4) Slower, since the round trip to client is involved
No comments:
Post a Comment