Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can one have multiple global-forward

 
jo sim
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like you already have all the answers. Looks correct to me.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
jo sim
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys.
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it will be override with local
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic