Friday, July 31, 2009

Difference between redirect and forward

If a request is forwarded to another request, all name/value pairs stored in the request scope are carried over to the new request. On the other hand, if a request is redirected, the request data are lost.

Another important point to understand about sendRedirect() is that the browser goes to the second resource only after it receives the redirect message from the first resource. In that sense, sendRedirect() is not transparent to the browser. In other words, the servlet sends a message telling the browser to get the resource from elsewhere.

No comments: