This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

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

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" />
If you like strawberry rhubarb pie, try blueberry rhubarb (bluebarb) pie. And try this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!