title: Passing a parameter from JSP to action class in Struts 2
body: <p>I am trying to pass value of a text-field as a URL parameter from a JSP to an action class on clicking of a button(non-submit button) and have found a solution in this link: <a href="https://stackoverflow.com/questions/12948226/onchange-event-in-struts2">Onchange event in Struts2</a>. </p>
  
  <p>I have followed all the steps mentioned in that link i.e.:</p>
  
  <ul>
  <li>creating a javascript function for <code>onClick</code> event </li>
  <li>inside the function i.e. <code>setDealers</code>, passing the value i.e. <code>"reportGroup"</code> to the action class as shown below</li>
  </ul>
  
  <pre class="lang-js prettyprint-override"><code>function setDealers(){
    var rep_value=document.getElementById("reportGroup").value;
    alert("Value is"+rep_value);
    window.location=="getDealersByGrouppopUpAction?reportGroup="+rep_value;
    alert("Just a check")
  }
  </code></pre>
  
  <ul>
  <li>created a variable with name <code>"reportGroup"</code> in the action class i.e. <code>PopUpAction.java</code> with getters and setters for it.</li>
  </ul>
  
  <p>Also to support all this, I have following configuration in <code>struts.xml</code>:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;action name="*popUpAction" class="popUpAction" method="{1}" &gt; 
      &lt;!--this will call a desired method present inside action class --&gt; 
      ...
      ...
  &lt;/action&gt;
  </code></pre>
  
  <p>On clicking of the button, <code>getDealersByGroup</code> method of <code>PopUpAction</code> class is supposed to be invoked and use the passed value i.e. <code>"reportGroup"</code> in a SQL query.
  But as per the above javascript function <code>setDealers</code> only alert commands are getting executed and the desired value is not getting passed to the action class.</p>
  
  <p>Is there any thing missing/ or wrong with <code>struts.xml</code>. </p>