You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian Holzer <bh...@sgi.sk.ca> on 2002/01/24 21:46:27 UTC
redirect vs forward
Hey there,
I am kind of confused about what the difference is between a forward and a redirect. In reading the documentation on the logic:forward and redirect tags. With the forward tag, whether a forward or redirect is sent, is determined by the redirect param in the <action> definition. The redirect tag sends a redirect to the browser, but what is the difference between the two? Why would I want to define an Actions forward so that it is sent as a redirect? Maybe the answer will be evident to me once I know the difference b/t the two. Can someone shed some light on this for me?
Brian
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: redirect vs forward
Posted by Ted Husted <hu...@apache.org>.
Here's a neat circumstance for a redirect.
There's a batch process that the user's can run to get the latest
whatever. When it runs, it marks the current records as being done,
since the process is meant to run once per record. A good way to do this
is to run the process, and then redirect to another Action that displays
the result of the process. This way if the user hits reload or refresh,
they won't run a new batch, but redisplay the current one (which is what
they probably wanted).
/do/batch/Run -> (mark records) -> (redirect) -> /do/batch/View?batch=42
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/
Brian Holzer wrote:
>
> Hey there,
> I am kind of confused about what the difference is between a forward and a redirect. In reading the documentation on the logic:forward and redirect tags. With the forward tag, whether a forward or redirect is sent, is determined by the redirect param in the <action> definition. The redirect tag sends a redirect to the browser, but what is the difference between the two? Why would I want to define an Actions forward so that it is sent as a redirect? Maybe the answer will be evident to me once I know the difference b/t the two. Can someone shed some light on this for me?
>
> Brian
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: redirect vs forward
Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "Brian" == Brian Holzer <bh...@sgi.sk.ca> writes:
Brian> Hey there,
Brian> I am kind of confused about what the difference is between a forward and a redirect. In reading the documentation on the logic:forward and redirect tags. With the forward tag, whether a forward or redirect is sent, is determined by the redirect param in the <action> definition. The redirect tag sends a redirect to the browser, but what is the difference between the two? Why would I want to define an Actions forward so that it is sent as a redirect? Maybe the answer will be evident to me once I know the difference b/t the two. Can someone shed some light on this for me?
Other people will hopefully provide more detail, but in short, a "forward"
(without redirect) is like a "function call" on the server side. It just
transfers control of the servlet output from the current servlet to a different
one. A "redirect", however, sends a new URL back to the browser, which then
visits that URL.
One common issue that people run into is that you retain the original request
parameters in a forward, but not in a redirect.
Hopefully someone else can provide more information on the motivations for
choosing a forward or redirect.
--
===================================================================
David M. Karr ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: redirect vs forward
Posted by Joel Barnum <jb...@descriptor.com>.
Brian Holzer wrote:
> Hey there,
> I am kind of confused about what the difference is between a forward and a redirect.
>
> Brian
Brian,
Forwarding takes place entirely on the server, while redirecting sends a
command back to the browser so that the browser opens a connection to
a different URL. Redirecting is slower, but has some advantages. For
example, the browser shows the redirected URL while if you forward, the
browser shows the original URL.
Joel
--
-------------------------------------------------
Descriptor Systems
Java, C++ and XML Training and Courseware
www.descriptor.com
-------------------------------------------------
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: redirect vs forward
Posted by Alex Paransky <al...@individualnetwork.com>.
A forward is something that occurs on the server side and the browser is not
aware of it. A redirect, is something that comes back to the browser, and
causes it to make a new requires (redirect) right way. The browser is aware
of it and that changes the URL that the browser is pointing to.
For example, if you forward from One.jsp to Two.jsp, the browser will show
One.jsp in the URL. On the other hand if you redirect the browser will show
Two.jsp.
-AP_
-----Original Message-----
From: Brian Holzer [mailto:bholzer@sgi.sk.ca]
Sent: Thursday, January 24, 2002 12:46 PM
To: struts-user@jakarta.apache.org
Subject: redirect vs forward
Hey there,
I am kind of confused about what the difference is between a forward and
a redirect. In reading the documentation on the logic:forward and redirect
tags. With the forward tag, whether a forward or redirect is sent, is
determined by the redirect param in the <action> definition. The redirect
tag sends a redirect to the browser, but what is the difference between the
two? Why would I want to define an Actions forward so that it is sent as a
redirect? Maybe the answer will be evident to me once I know the difference
b/t the two. Can someone shed some light on this for me?
Brian
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: redirect vs forward
Posted by Sean Owen <sr...@yahoo.com>.
Say a browser requests page "A" in an application.
If the application responds by forwarding to "B", then a
server-side forward takes place; the server sends back the
contents of "B" but the browser doesn't know the difference. It
asked for "A" and got something back that happened to actually
be "B".
If the applications responds by redirecting to "B", then the
server sends back a message saying "please ask me for B". The
browser then requests "B" and gets it.
Either way it gets the same thing, but the mechanism is quite different.
A redirect obviously involves some more overhead to get from A
to B, so to speak. You generally don't need to redirect.
An example of when you need redirect that comes to mind is when
you want to forward to a URL on another server... you can't do a
server-side forward in that case.
Sean
On Thursday, January 24, 2002, at 03:46 PM, Brian Holzer wrote:
> Hey there,
> I am kind of confused about what the difference is between
> a forward and a redirect. In reading the documentation on the
> logic:forward and redirect tags. With the forward tag, whether
> a forward or redirect is sent, is determined by the redirect
> param in the <action> definition. The redirect tag sends a
> redirect to the browser, but what is the difference between the
> two? Why would I want to define an Actions forward so that it
> is sent as a redirect? Maybe the answer will be evident to me
> once I know the difference b/t the two. Can someone shed some
> light on this for me?
>
> Brian
>
>
> --
> To unsubscribe, e-mail: <mailto:struts-user-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:struts-user-
> help@jakarta.apache.org>
>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: redirect vs forward
Posted by Robert Nocera <rn...@neosllc.com>.
A redirect tells the browser to load a new page whereas a forward sends
the current request on to a new action or page. The big difference is
that in a redirect the browser is making a *new* request, in a forward,
the current request is carried on to wherever with all the attributes of
the original request.
Another consideration is that when a redirect is done, the client now
knows where they were redirected to, whereas multiple forwards can be
performed and the client only knows about the original request that was
made.
Robert Nocera
New England Open Solutions
www.neosllc.com
"You supply the vision, we'll do the rest."
-----Original Message-----
From: Brian Holzer [mailto:bholzer@sgi.sk.ca]
Sent: Thursday, January 24, 2002 3:46 PM
To: struts-user@jakarta.apache.org
Subject: redirect vs forward
Hey there,
I am kind of confused about what the difference is between a forward
and a redirect. In reading the documentation on the logic:forward and
redirect tags. With the forward tag, whether a forward or redirect is
sent, is determined by the redirect param in the <action> definition.
The redirect tag sends a redirect to the browser, but what is the
difference between the two? Why would I want to define an Actions
forward so that it is sent as a redirect? Maybe the answer will be
evident to me once I know the difference b/t the two. Can someone shed
some light on this for me?
Brian
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>