This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
We know that incase of forward there is not a full network round trip and same request object is forwarded .. while in sendRedirect there is a full network roundtrip and a new request object is created. there is a temptation to use forward. The Question is that in what cases we should prefer to use the sendRedirect method instead of forward ? which one is better and why ?
Hi, Your answer is true from the resultant effect point of view. But at the background, redirect results in forwarding the URL to the client and client re-requesting the URL. Forward - is a kind of redirect to the resource within the same server - no client involvement is required Redirect - as explained above therefore, use forward when the redirected resource resides on the same server and use redirect when the resource resides on a different server Hope this clarifies Rgds Muthu
You might consider redirect when you want the browser client to know the new URL. That lets the user refresh or bookmark the page. TheServerSide.com proposed a pattern of posting an edit form to the server, then redirecting the browser to an inquiry URL that displays the changed content. The overhead of a second request-response cycle may be acceptable given the improved usability of the site.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi