title: Java Struts 1: forward from action to action. Passing data through ActionForms
body: <p>We've been trying to redirect from one action to another, hoping that data would be passed between corresponding <code>ActionForm</code> beans. The first action receives a request from the browser, prints a data field, and forwards it to another action, which prints the same field and redirects to a JSP. </p>
  
  <p>The problem is that <code>ActionTo</code> is printing an incorrect value - its <code>commonInt</code> has a default value of <code>0</code>, while we expect <code>35</code>.</p>
  
  <p>Here is a representing example:</p>
  
  <pre><code>public class ActionFrom extends DispatchableAction{
  
      public ActionForward send(ActionMapping mapping, ActionForm form, HttpServletRequest request,HttpServletResponse response){
          FormA formA = (FormA)form;
  
          formA.commonInt = 35;
          System.out.println("sent: "+formA.commonInt);
          return mapping.findForward("send");
      }
  }
  
  public class ActionTo extends DispatchableAction{
  
      public ActionForward recv(ActionMapping mapping, ActionForm form, HttpServletRequest request,HttpServletResponse response){
          FormB formB = (FormB)form;
  
          System.out.println("recv= "+formB.commonInt);
  
          return mapping.findForward("send");
      }
  }
  </code></pre>
  
  <p>And actionForms are:</p>
  
  <pre><code>public class FormA extends ActionForm {
      public int intA;
      public int commonInt;
  }
  
  public class FormB extends ActionForm{
      public int intB;
      public int commonInt;
  }
  </code></pre>
  
  <p>Mappings:</p>
  
  <pre><code>&lt;action path="/from" type="EXPERIMENT.ActionFrom" name="formA" scope="request"
        input="something.jsp" parameter="dispatch" unknown="false" validate="false"&gt;
   &lt;forward  name="send" path="/to.do?dispatch=recv" redirect="false"/&gt;
  &lt;/action&gt;
  
   &lt;action path="/to" type="EXPERIMENT.ActionTo" name="formB"  scope="request"
        input="something.jsp" parameter="dispatch" unknown="false" validate="false"&gt;
        &lt;forward name="send" path="/login.do"  redirect="false"/&gt;
   &lt;/action&gt;
  </code></pre>
  
  <p>Is there a way to accomplish this? Or both forms should be the same?</p>
  
  <p>The workaround we tried was to pass things through request, but it can get large and messy.</p>