aspose file tools*
The moose likes Struts and the fly likes can one have multiple global-forward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "can one have multiple global-forward" Watch "can one have multiple global-forward" New topic
Author

can one have multiple global-forward

jo sim
Ranch Hand

Joined: Apr 24, 2006
Posts: 37
Hi can I have multiple <global-forward> in struts xml file?

<global-forwards>
<forward name="home" path="/index.jsp" redirect="true"/>
<forward name="us" path="/us.jsp" redirect="true"/>
</global-forwards>

also how can one use this in action class? for example
return mapping.findFoward("forwardname") (IS THIS CORRECT AND WILL IT WORK)
Chris Boldon
Ranch Hand

Joined: Aug 10, 2006
Posts: 190
Sounds like you already have all the answers. Looks correct to me.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Yes, you can define multiple global forwards. Your code is correct. Forwarding to a global forward is no different than forwarding to a local forward. The only difference is that a global forward can be found from any action, whereas a local forward can be found only from the action for which it is defined. Just make sure that you don't define a global and local forward with the same name.


Merrill
Consultant, Sima Solutions
jo sim
Ranch Hand

Joined: Apr 24, 2006
Posts: 37
Thank you guys.
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Just make sure that you don't define a global and local forward with the same name.

For the record, this is something that I do often. For example I have a global forward named "failure" that forwards to the default error page. In some cases the action knows how to handle an error so the action definition will provide its own "failure" forward. Based on my experience, the local forward will override the global forward for that action.

- Brent
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Good point, Brent.

However, I do remember helping someone through a nasty problem that was caused by him thinking the Action was forwarding to one forward, when it was actually forwarding to another because he had inadvertently defined both a local and global forward with the same name. It's still something to watch out for.
Muthu Msamy
Greenhorn

Joined: Jul 03, 2013
Posts: 1
Yes, it will be override with local
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can one have multiple global-forward
 
Similar Threads
Can I make a global forward pointing to an Action?
Duplicate action and path
action forward problem : when "Failure"
Global Forward with Redirect="true"
context and action classes