Difference Between Forward And sendRedirect In Servlet
Contents
forward() and sendRedirect() Difference
The Key Difference between forward() and sendRedirect() is that forward() method works at server-side. whereas sendRedirect() method works at client side.
- forward(): This method is declared in RequestDispatcher Interface.
- sendRedirect(): This method is declared in HttpServletResponse Interface.

forward() and sendRedirect() Comparison Chart
forward() | sendRedirect() |
---|---|
forward() is method of RequestDispatcher interface | sendRedirect() is the method of HttpServletResponse In forward(). |
In forward() redirect happens at server end and not visible to client. | In sendRedirect() ,redirection happens at client end and it’s visible to client. |
It is faster than the redirect. | It is slower than a forward, since it requires two browser requests(one for actual request and another for redirected request ). |
In case of forwarding() original URL remains unaffected. | In the case of sendRedirect() browser knows that it’s making a new request, so the original URL changes. |
Transfer the request to the same server. | Transfer the request different server. |
When forward is called on RequestDispather object we pass request and response object so our old request object is present on a new resource which is going to process our request | In the case of SendRedirect call old request and response, the object is lost because it’s treated as a new request by the browser |
Syntax: forward(ServletRequest request, ServletResponse response) | Syntax: void sendRedirect(String url) |
More Difference
- Difference between include() and forward()
- Difference Between GenericServlet and HttpServlet
- Difference between Session and Cookies