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...

1 - In forward, the processing takes place at server side. In case of sendRedirect() the processing takes place the client side.

2 - 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.

3 - In forward only one request call is consumed. In case of sendRedirect two request response calls are created and consumed.

4 - The forward is declared in RequestDispatcher interface. Where as sendRedirect is declared in HttpServletResponse object.



You May Interest

What is the Difference Between an ArrayList and a LinkedList Data ...

What are the Similarities Between HashSet and HashMap in Java ?

What is Difference Between Include Directive and Include Action o ...

Why Collection Interface Doesn’t Extend Cloneable and Serializabl ...

What are the Differences Between Internal and External Iterator i ...