Manish
Posts: 2
Nickname: manish22nd
Registered: Jun, 2003
|
|
Re: Refirect and Forward
|
Posted: Jun 18, 2003 1:31 AM
|
|
> Hi > Whatis the basic different of Refirect and Forward > methods, nd which one is the fast, and also what is exact > meaning of "peer" classes
The forward method works inside the Web container. When you forward, the target page is invoked by the JSP container through an internal method call; the new page continues to process the same request and the browser is not aware of the fact that more than one page is involved. 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. Another difference is that request scope objects are no longer available after a redirect because it results in a new request. If you need to pass data to the page you redirect to, you have to use a query string and pass them as request parameters (or save the data as session or application scope objects). Conclusion: Use the forward method if it can solve your problem. Resort to the sendRedirect method only if you can't use the forward method. Forwarding is always faster, so that's the first choice.
|
|