What is the difference between RequestDispatcher‘s forward() and HttpServletResponse‘s sendRedirect() method?
Can anyone explain with a example and best usage of these methods with a real time example?
What is the difference between RequestDispatcher ‘s forward() and HttpServletResponse ‘s sendRedirect() method? Can
Share
Redirection is a type of response sent back to the client, whereas the forward delegation takes place completely on the server side and the result of the forward action returns to the client as if it came only from the original URL.
Another difference is that forward delegation can be used only for in-applications resources, whereas redirection
command can redirect the client browser outside the current domain.
Examples:
Another good explanation can be found here:
Difference between sendRedirect() and forward()