Struts

Name:
Location: Bangalore, India

Wednesday, February 27, 2008

Action Chaining

<action
path="/app/summaryRequestMaturityDate"
name="RequestForm"
scope="session"
validate="true"
input="/jsp/request/jsp/ViewSummary.jsp"
type="com.abc.gcib.ijk.action.request.SummaryRequestAction">
<forward name="success" path="/jsp/request/jsp/SubmitCompletedSummary.jsp " />
<forward name="maturityDateCalculator" path="/app/maturityDateCalculator.do" redirect="true"/>
<forward name="failure" path="/jsp/request/jsp/ ViewSummary.jsp" />

Action chaining is nothing but calling another action class instead of forward to a page in struts mapping. We need to include the redirect attribute in the forward tag. If redirect is set to true then, the values that are set in the first action class can be accessed in the forwarded action class. If the redirect attribute is not present then if any of form property value that is processed and reset in the first action class won’t be available in second action class. Second action class will pick the stale value from the session instead of the new value from first action class. In this case we must use request attributes to set those property values in first action class and retrieve in second action class. To avoid all these extra coding and confusion, it’s better to use redirect attribute and set the value to true.

As a rule, Action Chaining is not recommended.

Link-I