Forward vs Redirect
These are the two methods of transferring the control between web pages,the purpose of both is almost same but there is some difference which i am going to tell you here.
Redirect: If you want to implement this redirecting process in jsp you have to follow this syntax:
<c:redirect url="targetPageURL">
>> where c is nothing but prefix for core JSTL actions we set at the beginning of every jsp page to use Java Standard Tag Library .
we include tag libraries in our page this way :
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
Note:you can provide some other prefix aswell but c is recommended so that you don't catch a reserved keyword.
Now moving to the main point
Redirecting will pass the control to the page specified in the url attribute of tag. This control transfer make browser to request the new page in a formal way,and the address in the address bar of browser changes to the url of new page as the page is loaded.
So the URL in the address bar of the browser will remain same even though new page has been loaded.
Forward | Redirect |
---|---|
-> It request the new page implicitly without letting browser know about the control transfer. | -> It request the new page with the help of browser in a formal way. |
-> URL in the address bar of the browser remain intact indicating previous page. | -> URL changes to the new page automatically |
-> Transfers all the request parameters to the target page. | -> It doesn't transfer request scope parameters to the target page. |
No comments:
Post a Comment