What is the difference between sendRedirect and forward in a JSP?

Both forward and sendRedirect are mechanisms of sending a client to another page. The main difference between these two are as follows:

<li>In forward, the processing takes place at server side. In case of sendRedirect() the processing takes place the client side.</li>

<li>In forward, the request is transferred to another resource within same server. In case of sendRedirect the request can be transferred to resource on some other server.</li>

<li>In forward only one request call is consumed. In case of sendRedirect two request response calls are created and consumed.</li>

<li>The forward is declared in RequestDispatcher interface. Where as sendRedirect is declared in HttpServletResponse object.</li>

Leave a Reply

Your email address will not be published. Required fields are marked *