This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Struts2- Persistence of objects values between different actions in the same Action class  RSS feed

crazyk crazy
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scenario: On click of a 'Submit' button I have unmarshalled the XML to Java and then displaying the Java objects(created a formbean and mapped the JAXB java Objects to this formbean- PolicyForm and using this formbean to display in JSP) in the JSP.This is working fine.

Issue: I have one more button -Calculate on the same page with in the same form of Submit button. On click of the 'Calculate' button I need to get the acordform values which was unmarshalled during the click of Submit button. Here I am not able to get the acordform values instead I am getting the new object of acordform.

When I have googled I see- Struts 2 doesn't have thread-safety issues as "Action objects are instantiated for each request". Please let me know here when I am sending the request again is the Action object- acordform being instantitaed everytime? If yes, how can I avoid this ? Since I need the acordformobject values even in the next request too.

Action Class:
public class RateAction extends ActionSupport implements
ServletRequestAware,SessionAware {

/* ... */

// ACORD xml form bean
private ACORD acordform = new ACORD();

//To display the values in the JSP
private PolicyForm policyForm;

public ACORD getAcordform() {
return acordform;

public void setAcordform(ACORD acordform) {
this.acordform = acordform;

public String doSubmit() {
/*...Unmatshalling from XML to Java -acordform is done..*/

public String doRateSubmimt()
/*..trying to get the acordform values which are being set
previously in doSubmit() method...*/

<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />
<constant name="struts.custom.i18n.resources" value="ApplicationResources" />
<package name="default" extends="struts-default" namespace="/" >

<action name="fileUploadAction"
class="com.main.common.action.RateAction" >
<interceptor-ref name="fileUpload">
<param name="allowedTypes">text/xml</param>
<interceptor-ref name="defaultStack"></interceptor-ref>
<interceptor-ref name="params"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="basicStack"/>
<result name="success">First.jsp</result>
<result name="input">First.jsp</result>

<action name="submitAction" class="com.main.common.action.RateAction" method="doSubmit">
<result name="success">First.jsp</result>
<action name="rateAction" class="com.main.common.action.RateAction" method="doRateSubmit">
<result name="success">First.jsp</result>


<s:form id="rtr" action="fileUploadAction" method="POST"
<table border="0" cellspacing="0" cellpadding="0">
<s:file name="uploadFile" label="Upload Request XML" />
<s:submit value="Submit" action="submitAction" onclick="displayDetails();" />
<s:hidden name="submitSuccess" />
<s:submit value="Calculate" action="rateAction" />
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!