aspose file tools*
The moose likes Struts and the fly likes Difference between <forrward> in <action-mappings> and <forward> in <global-forwards> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Difference between <forrward> in <action-mappings> and <forward> in <global-forwards>" Watch "Difference between <forrward> in <action-mappings> and <forward> in <global-forwards>" New topic
Author

Difference between <forrward> in <action-mappings> and <forward> in <global-forwards>

Deepaks Deshpande
Ranch Hand

Joined: Dec 06, 2007
Posts: 113

Hi,

What is the difference between <forward> declared in the <global-forwards> tag and <forward> declared in the <action-mappings> tag. Also both the <forward> tags have the same attributes as well. i.e "name" and "path".

Thank you.


Regards,
Deepak

lalit upadheyay
Ranch Hand

Joined: Jun 20, 2005
Posts: 110
A global forward is defined in a Struts configuration file and invoked in a JSP page. A local forward is defined in a Struts configuration file in an action mapping and is invoked when the action is invoked.

Following is an example of global forwards in the struts-config.xml file of the struts-example sample application:



The logoff forward is invoked in mainMenu.jsp as follows:
test.jsp:
<html:link forward="logoff"><bean:message key="mainMenu.logoff"/></html:link>

Another example for global forward is:


index.jsp:
<logic:forward name="init"/>

Note: we can get a reference to global and local forward in an action using actionmapping.findforwsrd(String) method.


SCJP1.4, SCWCD1.4, SCBCD5.0(working on...)
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Global forwards are available across the entire application. "Local" forwards are available only within the action that defines them.
Deepaks Deshpande
Ranch Hand

Joined: Dec 06, 2007
Posts: 113

Thank you Lalit and David.
 
 
subject: Difference between <forrward> in <action-mappings> and <forward> in <global-forwards>