Creating global forwards

A Struts forward is an object that is returned by an action and has two fields: a name and a path. The path is typically the URL of a JSP file; the path indicates where a request is to be forwarded. A forward can be local (pertaining to a specific action) or global (available to any action).

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. For more information about Struts configuration files and action mappings, see the related references.

To create a global forward:

  1. In Enterprise Explorer, expand your Web project then click

    Struts | <module>, where <module> is the Struts module for which you want to create the global forward.

  2. Right-click

    Global Forwards and click

    New | Global Forward. The Struts Configuration File opens in the editor and the global forward is created.

  3. Configure the forward attributes and mapping extensions.

  4. Save the Struts Configuration File.

 

Example of global forwards

The following example of global forwards is in the

struts-config.xml Struts configuration file in the

struts-example sample application:

<global-forwards>
  <forward name="logoff" path="/logoff.do"/>
  <forward name="logon" path="/logon.jsp"/>
  <forward name="success" path="/mainMenu.jsp"/>
</global-forwards>

The logoff forward is invoked in

mainMenu.jsp as follows:

<html:link forward="logoff"><bean:message key="mainMenu.logoff"/></html:link>