Difference b/w sendRedirect & forward?

Posted: June 22, 2009 in Java
  • RequestDispatcher.forward() and HttpServletResponse.sendRedirect() are the two methods available for URL redirecting to another jsp or servlet
  • sendRedirect() is more flexible than forward() because with sendRedirect() you can connect to any URL outside the webapplication whereas forward() will work only within the web application.
  • sendRedirect() is slower than forward()
  • sendRedirect() is on the client side where as forward() is on the server side.
  • In case of forward(),  web server shows the content of forwarded page without leting the user client knowing about the source.where as in redirect(), a new url is returned back to user client and then user client makes a new request to new url to fetch the content.
  • If you use sendRedirect() then no request-response objects will be available.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s