forward() and sendRedirect()

forward() method  


  1. The forward() method works at server side.
  2. The forward() method work within the server only.
  3. It sends the same request and response objects to another servlet.
  4. Visually we are not able to see the forwarded address, its is transparent
  5. Using forward () method is faster then send redirect.

Example:


request.getRequestDispacher("SecondServlet").forward(request,response);


sendRedirect() method


  1. The sendRedirect() method works at client side.
  2. It can be used within and outside the server.
  3. It always sends a new request.
Example: 


response.sendRedirect("SecondServlet");