☰ See All Chapters |
Difference between forward() and sendRedirect()
forward() | sendRedirect() |
forward() is a method in RequestDispatcher | sendRedirect() is a method in HttpServletResponse. |
Redirection will happen from server | Redirection will happen from client after response is given to the client. |
request and response objects are required. | Only response object is required. |
We can use the relative path for forwarding. | We have to use the absolute path for redirecting. |
The request can be transferred to another resource only within the server. | The request can be transferred to another resource both within and outside the server. |
It is faster and efficient. | It is slower. |
All Chapters