You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mu Mike <mi...@hotmail.com> on 2004/04/15 11:30:24 UTC
what is the difference between forward and redirect?
when forward, what do we foward?
when redirect, what we do different?
Thanks&Regards
Mike
_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: what is the difference between forward and redirect?
Posted by "Steven J. Owens" <pu...@darksleep.com>.
On Thu, Apr 15, 2004 at 04:33:42PM -0700, Craig McClanahan wrote:
> Christian Bollmeyer wrote:
> >1. You've reached the end of a processing chain
> >and want to leave the user at a determined
> >application state, a point from which he may
> >start another interaction with the application,
> >but everything else is done and finished.
> >Such as redirecting to the starting page
> >after a 'wizard' has completed.
>
> A variation on this same theme is if you want to leave the user a point
> at which they can save a bookmark to this spot in your application, you
> need to use a redirect. Otherwise, the URL being bookmarked will not be
> correct (it will be the URL to which the last form submit occurred,
> rather than the page being displayed).
Another nuance, which I find comes in handy quite often, is that
responding to a form submit with a redirect will prevent the browser
from offering to re-post the parameters for the user.
--
Steven J. Owens
puff@darksleep.com
"I'm going to make broad, sweeping generalizations and strong,
declarative statements, because otherwise I'll be here all night and
this document will be four times longer and much less fun to read.
Take it all with a grain of salt." - Me at http://darksleep.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: what is the difference between forward and redirect?
Posted by Craig McClanahan <cr...@apache.org>.
Christian Bollmeyer wrote:
>[snip]
>1. You've reached the end of a processing chain
>and want to leave the user at a determined
>application state, a point from which he may
>start another interaction with the application,
>but everything else is done and finished.
>Such as redirecting to the starting page
>after a 'wizard' has completed.
>
>
>
A variation on this same theme is if you want to leave the user a point
at which they can save a bookmark to this spot in your application, you
need to use a redirect. Otherwise, the URL being bookmarked will not be
correct (it will be the URL to which the last form submit occurred,
rather than the page being displayed).
Craig
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: what is the difference between forward and redirect?
Posted by Christian Bollmeyer <ja...@christianbollmeyer.de>.
On Thursday 15 April 2004 11:30, Mu Mike wrote:
Simple 'rule of thumb': whenever possible, use
a forward. Use redirects only if:
1. You've reached the end of a processing chain
and want to leave the user at a determined
application state, a point from which he may
start another interaction with the application,
but everything else is done and finished.
Such as redirecting to the starting page
after a 'wizard' has completed.
2. Interaction with external systems, such
as a payment system provider who
chose Perl, PHP or Microsoft for their
implementation. Well, to be honest;
even if it were Java, it would make no
difference here, Once you leave your
server | JVM, all the benefits of the
Servlet API are gone for good from
your perspective, and there's no
way to get around it.
Why? After a redirect, the request isn't
the same anymore. The server simply
issues a status code that tells the
browser to try again at the given URL,
and if the user hasn't disabled this
feature (which is possible in some
browsers), it will go there automatically.
But in any case, this ends up in an entirely
new request. Where in a forward you
have all the power of the Java Server
in your back, in a redirect situation
you're doomed to passing any infor-
mation by HTTP means, namely by
parameters. Sometimes, that's
necessary, harmless or even intended
(a redirect updates the browser
command line, so the user knows
where he is again), but whenever
possible, use forwards.
May the server be with you, and
HTH,
-- Chris.
> when forward, what do we foward?
> when redirect, what we do different?
>
> Thanks&Regards
> Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org