jsp:redirect page="url"
The code above will be translated into:
RequestDispatcher rd = request.getRequestDispatcher(url);
rd.forward(request, response);
Both Forward and Redirect tags are essentially the same.
They redirect request from a JSP to another URL
jsp:forward page="url"
The code above will be translated into:
RequestDispatcher rd = request.getRequestDispatcher(url);
rd.forward(request, response);
jsp:forward page="url"
The JSP tag above will forward unhandled exceptions to the specified url for error handling
Both Forward and Redirect tags are essentially the same.
They redirect response to a different client
Expalanation
Objective: JSP expressions
jsp:forward page="url" will forward request from a current JSP to another URL.
The code above will be translated into:
RequestDispatcher rd = request.getRequestDispatcher(url);
rd.forward(request, response);
Here is the difference between Forward and Redirect:
Forward is performed internally by the servlet (or by a JSP converted into a servlet).
The same request comes to another servlet for a processing.
A browser takes no part in the process.
It is a different story with the Redirect.
The web application instructs the browser to fetch another URL.
An old request with all related data disappears and a new request from this new URL takes its place.
jsp:forward page="url" will forward request from a current JSP to another URL
|