Creating local 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).

  1. Create a Struts enabled Web project or enable an existing Web project with Struts support.

  2. Create a Struts action mapping.

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.

To create a local forward:

  1. In your Web diagram, hover over the action for which you want to create a local forward.

  2. Click the Add Local Forward icon. By default the success local forward is created first, the failure local forward is created second.

  3. To configure the local forward, double-click the local forward in your Web diagram. The Struts configuration file opens in the editor.

 

Example of local forwards

Following is an example of local forwards in the

struts-config.xml file of the

struts-example sample application:

<action 
		path="/editSubscription" 
		type="org.apache.struts.webapp.example.EditSubscriptionAction" 
		attribute="subscriptionForm" 
		scope="request" 
		validate="false">
	<forward 
			name="failure" 
			path="/mainMenu.jsp"/>
	<forward 
			name="success" 
			path="/subscription.jsp"/>
</action>