title: How can I pass form input value to an Action (struts 1)
body: <p>I'm new using struts.</p>
  
  <p>I need to pass the form value to an action when I submit the form. I want to use <strong>input tag</strong> no html:text.</p>
  
  <p>How to do it?</p>
  
  <p>This is my code:</p>
  
  <p>form in JSP:</p>
  
  <pre><code>&lt;form class="form-horizontal" action="address.do" method="post"&gt;
      Name: &lt;input type="text" class="form-control" name="name"&gt;&lt;br&gt;
      City &lt;input type="text" class="form-control" name="city"&gt;&lt;br&gt;
      Country: &lt;input type="text" class="form-control" name="country"&gt;&lt;br&gt;
      &lt;button class="btn btn-success" type="submit"&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>struts-config.xml:</p>
  
  <pre><code>&lt;form-beans&gt;
      &lt;form-bean name="myFrom" type="com.form.MyForm"/&gt;
  &lt;/form-beans&gt;
  
  &lt;global-forwards&gt;
      &lt;forward name="pagAddress" path="/address.do"/&gt;
  &lt;/global-forwards&gt;
  
  &lt;action-mappings&gt;
      &lt;action path="/address"
              type="com.action.MainAction"
              name="myForm"            
              scope="request" 
              input="/addressInput.jsp" 
              validate="true"&gt;
          &lt;forward name="success" path="/addressInput.jsp"/&gt;
      &lt;/action&gt;
  &lt;/action-mappings&gt;
  </code></pre>
  
  <p>ActionForm:</p>
  
  <pre><code>public class MyForm extends ActionForm{
  
  private static final long serialVersionUID = -XXXXXXXXXXXXXXXXXXXX;
  private String name = "";
  private String city = "";
  private String country = "";
  
  public String getName() {
      return name;
  }
  public void setName(String name) {
      this.name = name;
  }
  public String getCity() {
      return city;
  }
  public void setCity(String city) {
      this.city = city;
  }
  public String getCountry() {
      return country;
  }
  public void setCountry(String country) {
      this.country = country;
  }
  
  @Override
      public void reset(ActionMapping mapping, HttpServletRequest request) {
          this.name = null;
          this.city = null;
          this.country = null;
          super.reset(mapping, request);
      }
  
  }
  </code></pre>
  
  <p>Action:</p>
  
  <pre><code>public class MainAction extends Action {
  
     public ActionForward execute(ActionMapping mapping, ActionForm form,
          HttpServletRequest request, HttpServletResponse response)
          throws Exception {
          if(getErrors(request) == null ||getErrors(request).size() == 0)
              return mapping.findForward("success");
          else
              return mapping.getInputForward();
  
     }
  }
  </code></pre>