Following is the key difference between forward() and sendRedirect() :
- forward() sends the same request to another resource while sendRedirect() method sends new request always because it uses the URL bar of the browser.
- forward() method works at server side and sendRedirect() method works at client side.
- forward() method works within the server only and sendRedirect() method works within and outside the server.
sendRedirect() is used when we don´t want to send the same request on another page we received. Consider the example of login form : after successful login we should always use sendRedirect() to move to the welcome page. and similarly whenever we perform any successful database operation we always use sendRedirect(). On getting any error and exception we should use forward().