This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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.
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.
Joined: Feb 15, 2005
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.