aspose file tools*
The moose likes Struts and the fly likes By passing forward in action tag. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "By passing forward in action tag." Watch "By passing forward in action tag." New topic
Author

By passing forward in action tag.

Jose Mon
Ranch Hand

Joined: Feb 13, 2007
Posts: 30
Hi,

I had declared 2 forwards in the same name. 1 in <action> tag and other in <global-forwards>. But at a certain context can I skip the forward in the <action> tag so that it forwards the page defined in <global-forwards>
Is there any way for that?


<global-forwards>
<forward name="searching" path="searching_common.jsp"/>
</global-forwards>


<action path="/myURL" scope="session" type="myAction">
<forward name="searching" path="/searching.jsp"/>
</action>
RoshaniG Gopal
Ranch Hand

Joined: May 15, 2006
Posts: 180
Hi,
When you have the forwards first struts will search in the <action> and if it doesnt find it there then it will look for global forwards.
In case you want to have the global forward, then you have to change the name of the forward path in your action, or omit it altogether.
<global-forwards>
<forward name="searching" path="searching_common.jsp"/>
</global-forwards>
<action path="/myURL" scope="session" type="myAction">
<forward name="searching_new" path="/searching.jsp"/>
</action>[/


Regards,<br />Roshani
Jose Mon
Ranch Hand

Joined: Feb 13, 2007
Posts: 30
This is Ok, I know.
But I want to know is there any way to skip the forward in <action>
RoshaniG Gopal
Ranch Hand

Joined: May 15, 2006
Posts: 180
Its simple. Dont use the forward in the action. It will pick from the global-forwards.
<global-forwards>
<forward name="searching" path="searching_common.jsp"/>
</global-forwards>

<action path="/myURL" scope="session" type="myAction">
</action>
Jose Mon
Ranch Hand

Joined: Feb 13, 2007
Posts: 30
That I know.
I asked that if the same forward is defined in <action> and <global-forward> and is there any way to by pass the forward in <action>

For an interview, the interviewer asked this. For that only I asked this.
Jose Mon
Ranch Hand

Joined: Feb 13, 2007
Posts: 30
Is it possible?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
No, it's not possible. If you define forwards of the same name at both action level and global level, the one at the global level is inaccessible, since Struts will always pick the one at the action level.


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: By passing forward in action tag.