July 13, 2010

Redirect vs Forward


Redirect sends a response to the browser that forces the browser to make a new request. From the server point of view, the browser just makes a new request. Some characteristics of a redirect:
  • The existing parameters and attributes are disposed, a new request is formed with the parameters you specify in the URL.
  • The new URL is visible in the browser, the user can bookmark it.
  • It takes a trip to the browser and back, so it can be slower.
A forward happens on the server. The browser is not involved in this. Some characteristics of the forward:
  • New parameters are added or overwrite existing parameters. So the existing parameters cannot be removed from the request.
  • Stuff can be added in request context, it will remain available. You can pass information in this way.
  • The URL is not changed in the browser, for the browser the original address remains intact.
  • You can only forward to another URL in the same application.