Forward in JSP
posted 23 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
guys....I have been Haunted by this question by number of Interviewers . It's Kind of a pet question of the panel .
1) WHAT ARE THE DIFFERENT WAYS TO FORWARD TO ANOTHER RESOURCE IN JSP .
My Ans :- Using JSP Forward Tag , Using The RequestDispatcher interface method sendRedirect() or using the response.sendRedirect() method .
On hearing this , mostly I'am asked what are the differences in these three methods. could any one point out please !!!
Thanx in Advance !
1) WHAT ARE THE DIFFERENT WAYS TO FORWARD TO ANOTHER RESOURCE IN JSP .
My Ans :- Using JSP Forward Tag , Using The RequestDispatcher interface method sendRedirect() or using the response.sendRedirect() method .
On hearing this , mostly I'am asked what are the differences in these three methods. could any one point out please !!!
Thanx in Advance !
posted 23 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
The forward method works inside the Web container. The sendRedirect method requires a round trip to the client. So the forward method is faster than sendRedirect. However, using the forward method restricts you to redirect only to a resource in the same Web application. The sendRedirect method, on the other hand, allows you to redirect to any URL.
RequestDispatcher.forward() and PageContext.forward() are effectively the same. PageContext.forward is a helper method that calls the RequestDispatcher method.
the <jsp:forward..> is a forwarding of your request. What this means is that your request parameters (the request object)_ still remains current and you canstill access all its parameters. On the other hand the sendRedirct() is a NEW REQUEST. you loose all your request parameters. As you might guess <jsp:forward..> is faster. however it does have some problems specially when someone decides to lets say reload a page. The request will be sent again
RequestDispatcher.forward() and PageContext.forward() are effectively the same. PageContext.forward is a helper method that calls the RequestDispatcher method.
the <jsp:forward..> is a forwarding of your request. What this means is that your request parameters (the request object)_ still remains current and you canstill access all its parameters. On the other hand the sendRedirct() is a NEW REQUEST. you loose all your request parameters. As you might guess <jsp:forward..> is faster. however it does have some problems specially when someone decides to lets say reload a page. The request will be sent again
Anonymous
Ranch Hand
Posts: 18944
| Can you shoot lasers out of your eyes? Don't look at this tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |






