Simply difference between Forward
(ServletRequest request, ServletResponse response) and sendRedirect
(String url) is
forward():
forward()
method is executed in the server side.forward ()
method is provided by the servlet container.sendRedirect()
method.RequestDispatcher
interface.sendRedirect():
sendRedirect()
method is executed in the client side.sendRedirect()
method is provided under HTTP
so it can be used only with HTTP
clients.sendRedirect()
method is slower because when new request is created old request object is lost.HttpServletResponse
.