forward() sendRedirect()
Forward mechanism happing at server side and it is not visible to client.hence client doesn’t aware which servlet exactly providing the response send Redirection is happening at browser side hence client aware of which servlet is exactly providing required response
Recomended to use if you want communicate with in the webcontainer Recomended to use if you want communicate outside the webcontainer
No extra trip is required to the browser hence no network overhead problems and performance problem An extra trip is required to client side it may effect network overhead and performance problem
The same request object will be forwarded to the second Servlet hence information sharing b/w the components is possible in the form of request scoped(variable)attributes A new request object will be created hence there is no chance of sharing information b/w the components
By using RequestDispatcher object we can achieve forward By using ServletResponse object we can implement sendRedirection
After commiting the response we are not allowed to perform forward otherwise we will get IllegalStateException After commiting the response we are not allowed perform sendRedirection otherwise IllegalStateException