You need to use a forward if you are using Action.setMessages() or
Action.setErrors() in your action implementations. For example, I have
a BeanDeleteAction class. If an error occures in the action (an
exception being caught, wrong information being processed, database
down, etc) then I use setErrors() to display error messages to the user.
However, the error messages are stored in the request scope. Therefore,
in the error path of my action, I need to ensure that the ActionForward
that I return is of type forward and not redirect.
You will often see action mappings like this:
<action
path="/ZoneSave"
type="com.....SaveZoneAction"
name="ZoneForm"
validate="true"
input="/Zone.do">
<forward name="failure" redirect="false" path="/Zone.do" />
<forward name="success" redirect="true" path="/Zone.do" />
</action>
Where the failure path is a forward and the success is a redirect.
I also have code like this
try {
...
} catch (NCIException e) {
addError( request, .... );
ActionForward orig = mapping.findForward( "success" );
ActionForward f = new ActionForward( orig.getPath, false );
return f;
}
Where I force a redirect to be converted into a forward in order to have
request scoped objects remain in scope.
Well, this is the primary usage that I have for forwards. The rest of
the time, I basically use redirects.
I hope this helps.
JDG
PS: I'm sure the rest of the community will correct me if I'm wrong.
--
Jay Glanville
> -----Original Message-----
> From: Johannes Wolfgang Woger [mailto:[EMAIL PROTECTED]
> Sent: Thursday, April 15, 2004 8:27 AM
> To: Struts Users Mailing List
> Subject: Re: what is the difference between forward and redirect?
>
>
> Hi,
> I basically understood the technical diffence between forward
> and redirect,
> but from webapplications point of view, when do I use forward
> or redirect.
>
> On which circumstances should I use a redirect for example?
>
> Wolfgang
>
> Sanoj, Antony (IE10) wrote:
>
> >Mike,
> >
> > forward is carried inside the servlet engine, whereas the
> redirect goes to
> >the browser, and then the browser sends the request to the resource
> > forward preserves the request state, but redirect destroys
> the original
> >request as it completes a request/response cycle
> > when the browser receives the redirect.
> >regards
> >Sanoj
> >
> >-----Original Message-----
> >From: Mu Mike [mailto:[EMAIL PROTECTED]
> >Sent: Thursday, April 15, 2004 3:00 PM
> >To: [EMAIL PROTECTED]
> >Subject: 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: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]