response.sendRedirect() sets the http headers with the location="movedurl" and status accordingly and it lefts to the browser to fetch the moved page. after this method call response is closed any attempt to write will throws an Exception.
Where as requestDispatcher.forward() forwards internally (ie, browser wont come into picture) with this you can forward to only those
servlets which are in the same ServletContext as Forwarding Servlet. forward should be called before the response has been committed to the client (before response body output has been flushed). If the response already has been committed, this method throws an
IllegalStateException.
Sridhar
Originally posted by Luna Bora:
In forward, we can only specify the resources that are in the context of the web application, but using sendRedirect we can forward the request to any other resource which is not in the current context. Is this correct?
Thanks.