You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Phil <pe...@letthemusicplay.de> on 2003/11/05 12:51:24 UTC

Forward attribute vs. ForwardAction

Hi,

i write my thesis about the struts framework and i have a question about the
ForwardAction class. I think the forward attribute in an action-mapping has
the same effect as the use of the ForwardAction, so why is there a special
class to perform a forward?

I think you get the same result if you use:

<action
    path="/login"
    type="org.apache.struts.actions.ForwardAction"
    parameter="/login.jsp" />

or:

<action
    path="/login"
    forward="/login.jsp" />

So what is the benefit of the ForwardAction class?

Thanks,
Phil


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Forward attribute vs. ForwardAction

Posted by Phil <pe...@letthemusicplay.de>.
Hi Ashish,

thanks for your answer. But i think you missunderstood me. In the Struts
Framework, there is a prebuild Action class called ForwardAction.  The
ForwardAction and the forward attribute of an action-mapping (see my
example) serve the same purpose which is to forward from one JSP to another.
So you dont have to write your own Action class to achieve a simple forward
between two pages.
So, i am confused why there is a extra prebuild class, if you get the same
effect by using the forward attribute.

regards,
Phil


----- Original Message -----
From: "Ashish Sinha" <as...@kpitcummins.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, November 05, 2003 7:49 PM
Subject: Re: Forward attribute vs. ForwardAction


> Hi Phil,
>
>     If I understood you write, you have confusions over "forward" and
> "ForwardAction" due to the name you have chosen for the Action subclass.
> ForwardAction as you have defined in your "type" attribute could be named
> anything. A forward attribute in your struts configuration file tells the
> framework where to redirect/forward the control. There could be multiple
> entries for "forward" each pointing to different destinations and the one
> that is chosen depends on to what you forward from within Action subclass
in
> your case ForwardAction. They serve different purpose.
>
> Regards,
> Ashish.
> [Provedu do Bezkonechnostiu]
>
>
> ----- Original Message -----
> From: "Phil" <pe...@letthemusicplay.de>
> To: <st...@jakarta.apache.org>
> Sent: Wednesday, November 05, 2003 11:51 AM
> Subject: Forward attribute vs. ForwardAction
>
>
> > Hi,
> >
> > i write my thesis about the struts framework and i have a question about
> the
> > ForwardAction class. I think the forward attribute in an action-mapping
> has
> > the same effect as the use of the ForwardAction, so why is there a
special
> > class to perform a forward?
> >
> > I think you get the same result if you use:
> >
> > <action
> >     path="/login"
> >     type="org.apache.struts.actions.ForwardAction"
> >     parameter="/login.jsp" />
> >
> > or:
> >
> > <action
> >     path="/login"
> >     forward="/login.jsp" />
> >
> > So what is the benefit of the ForwardAction class?
> >
> > Thanks,
> > Phil
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Forward attribute vs. ForwardAction

Posted by Ashish Sinha <as...@kpitcummins.com>.
Hi Phil,

    If I understood you write, you have confusions over "forward" and
"ForwardAction" due to the name you have chosen for the Action subclass.
ForwardAction as you have defined in your "type" attribute could be named
anything. A forward attribute in your struts configuration file tells the
framework where to redirect/forward the control. There could be multiple
entries for "forward" each pointing to different destinations and the one
that is chosen depends on to what you forward from within Action subclass in
your case ForwardAction. They serve different purpose.

Regards,
Ashish.
[Provedu do Bezkonechnostiu]


----- Original Message -----
From: "Phil" <pe...@letthemusicplay.de>
To: <st...@jakarta.apache.org>
Sent: Wednesday, November 05, 2003 11:51 AM
Subject: Forward attribute vs. ForwardAction


> Hi,
>
> i write my thesis about the struts framework and i have a question about
the
> ForwardAction class. I think the forward attribute in an action-mapping
has
> the same effect as the use of the ForwardAction, so why is there a special
> class to perform a forward?
>
> I think you get the same result if you use:
>
> <action
>     path="/login"
>     type="org.apache.struts.actions.ForwardAction"
>     parameter="/login.jsp" />
>
> or:
>
> <action
>     path="/login"
>     forward="/login.jsp" />
>
> So what is the benefit of the ForwardAction class?
>
> Thanks,
> Phil
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Forward attribute vs. ForwardAction

Posted by Phil <pe...@letthemusicplay.de>.
Hi Rick,

thanks for your answer.
But if you defined the forward attribute no instance of the ForwardAction is
created. I checked the source code of the RequestProcessor.

Phil


----- Original Message -----
From: "Rick Reumann" <st...@reumann.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, November 05, 2003 5:56 PM
Subject: Re: Forward attribute vs. ForwardAction


> Phil wrote:
>
> > <action
> >     path="/login"
> >     type="org.apache.struts.actions.ForwardAction"
> >     parameter="/login.jsp" />
> >
> > or:
> >
> > <action
> >     path="/login"
> >     forward="/login.jsp" />
> >
> > So what is the benefit of the ForwardAction class?
>
> I'm not positive but I'm pretty sure both are using the
> ForwardAction class, the second approach above is just a shortcut
> version so you don't have to type out the FowardAction type = ""
> stuff. I could be wrong, though, so someone correct me if I am.
>
> --
> Rick
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Forward attribute vs. ForwardAction

Posted by Rick Reumann <st...@reumann.net>.
Phil wrote:

> <action
>     path="/login"
>     type="org.apache.struts.actions.ForwardAction"
>     parameter="/login.jsp" />
> 
> or:
> 
> <action
>     path="/login"
>     forward="/login.jsp" />
> 
> So what is the benefit of the ForwardAction class?

I'm not positive but I'm pretty sure both are using the 
ForwardAction class, the second approach above is just a shortcut 
version so you don't have to type out the FowardAction type = "" 
stuff. I could be wrong, though, so someone correct me if I am.

-- 
Rick


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Forward attribute vs. ForwardAction

Posted by Hubert Rabago <ja...@yahoo.com>.
Hi Phil,

Maybe my response was specific to a situation I had before.  In some of the apps
I've worked on, I needed to use my own RequestProcessor to insert some logic
before a <forward> is processed.  If I have <action>s that don't need an Action
object, using forward="myJsp.jsp" won't trigger the processForwardConfig(), in
which case my overridden RequestProcessor method doesn't get called.  With
ForwardAction, I wouldn't have to create a do-nothing action just to forward to a
JSP and ensure that processForwardConfig() still gets called.  In other apps
where I didn't need the custom processForwardConfig(), I still use ForwardAction
so in case I do need it in the future, I won't have to go back and remap
everything.  Who knows, maybe the next Struts version will behave differently
when all it has is forward="myJsp.jsp", though that part's just me guessing.
Like I said, it depends on your app, so it may or may not affect you.  Also,
check ForwardAction's javadoc for another example of its use.

HTH,
Hubert

--- Phil <pe...@letthemusicplay.de> wrote:
> Hi Hubert,
> 
> thanks for your answer.
> I thought of this too. But then i examined the source code of the
> RequestProcessor. There, the forward element is processed just before the
> operations which are related to the actions (like creating Action instances
> and calling the execute() method) are processed. After this there are no
> more features called. So i think using the forward attribute has no impact
> to any features of struts. All operations they need to work right are done
> before the forward attribute is processed.
> But maybe i didnt examine the source code right. If you know a case in which
> a feature does not work with the forward attribute this would be very
> helpful to me.
> 
> Phil
> 
> 
> ----- Original Message -----
> From: "Hubert Rabago" <ja...@yahoo.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Wednesday, November 05, 2003 5:39 PM
> Subject: Re: Forward attribute vs. ForwardAction
> 
> 
> > Phil,
> >
> > ForwardAction allows a response to still go through struts processing.
> > Not all of the Struts features will kick in or perform as expected
> > when you use forward="/login.jsp".
> > I don't have a full list of which ones will still work and which ones
> > won't, and it may depend on the complexity of your app, so it may or
> > may not affect you.  Think of ForwardAction as add'l future-proofing
> > for your app/action.
> >
> > Hubert
> >
> > --- Phil <pe...@letthemusicplay.de> wrote:
> > > Hi,
> > >
> > > i write my thesis about the struts framework and i have a question about
> the
> > > ForwardAction class. I think the forward attribute in an action-mapping
> has
> > > the same effect as the use of the ForwardAction, so why is there a
> special
> > > class to perform a forward?
> > >
> > > I think you get the same result if you use:
> > >
> > > <action
> > >     path="/login"
> > >     type="org.apache.struts.actions.ForwardAction"
> > >     parameter="/login.jsp" />
> > >
> > > or:
> > >
> > > <action
> > >     path="/login"
> > >     forward="/login.jsp" />
> > >
> > > So what is the benefit of the ForwardAction class?
> > >
> > > Thanks,
> > > Phil
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Protect your identity with Yahoo! Mail AddressGuard
> > http://antispam.yahoo.com/whatsnewfree
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Forward attribute vs. ForwardAction

Posted by Phil <pe...@letthemusicplay.de>.
Hi Hubert,

thanks for your answer.
I thought of this too. But then i examined the source code of the
RequestProcessor. There, the forward element is processed just before the
operations which are related to the actions (like creating Action instances
and calling the execute() method) are processed. After this there are no
more features called. So i think using the forward attribute has no impact
to any features of struts. All operations they need to work right are done
before the forward attribute is processed.
But maybe i didnt examine the source code right. If you know a case in which
a feature does not work with the forward attribute this would be very
helpful to me.

Phil


----- Original Message -----
From: "Hubert Rabago" <ja...@yahoo.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, November 05, 2003 5:39 PM
Subject: Re: Forward attribute vs. ForwardAction


> Phil,
>
> ForwardAction allows a response to still go through struts processing.
> Not all of the Struts features will kick in or perform as expected
> when you use forward="/login.jsp".
> I don't have a full list of which ones will still work and which ones
> won't, and it may depend on the complexity of your app, so it may or
> may not affect you.  Think of ForwardAction as add'l future-proofing
> for your app/action.
>
> Hubert
>
> --- Phil <pe...@letthemusicplay.de> wrote:
> > Hi,
> >
> > i write my thesis about the struts framework and i have a question about
the
> > ForwardAction class. I think the forward attribute in an action-mapping
has
> > the same effect as the use of the ForwardAction, so why is there a
special
> > class to perform a forward?
> >
> > I think you get the same result if you use:
> >
> > <action
> >     path="/login"
> >     type="org.apache.struts.actions.ForwardAction"
> >     parameter="/login.jsp" />
> >
> > or:
> >
> > <action
> >     path="/login"
> >     forward="/login.jsp" />
> >
> > So what is the benefit of the ForwardAction class?
> >
> > Thanks,
> > Phil
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> Protect your identity with Yahoo! Mail AddressGuard
> http://antispam.yahoo.com/whatsnewfree
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Forward attribute vs. ForwardAction

Posted by Hubert Rabago <ja...@yahoo.com>.
Phil,

ForwardAction allows a response to still go through struts processing.
Not all of the Struts features will kick in or perform as expected 
when you use forward="/login.jsp".
I don't have a full list of which ones will still work and which ones
won't, and it may depend on the complexity of your app, so it may or
may not affect you.  Think of ForwardAction as add'l future-proofing
for your app/action.

Hubert

--- Phil <pe...@letthemusicplay.de> wrote:
> Hi,
> 
> i write my thesis about the struts framework and i have a question about the
> ForwardAction class. I think the forward attribute in an action-mapping has
> the same effect as the use of the ForwardAction, so why is there a special
> class to perform a forward?
> 
> I think you get the same result if you use:
> 
> <action
>     path="/login"
>     type="org.apache.struts.actions.ForwardAction"
>     parameter="/login.jsp" />
> 
> or:
> 
> <action
>     path="/login"
>     forward="/login.jsp" />
> 
> So what is the benefit of the ForwardAction class?
> 
> Thanks,
> Phil
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org