title: Struts2 sending list data from JSP to Action class: alternative way
body: <p>I was explaining to a colleague the way of getting list data from a JSP page to back to the action class by using indices as explained <a href="https://stackoverflow.com/questions/19551984/get-the-list-object-value-from-a-jsp-to-action-class">here</a> and <a href="https://stackoverflow.com/questions/19045068/sending-multiple-rows-of-a-form-created-by-iterator-to-action">here</a>. He didn't quite understand and fumbled a bit on his own until he suddenly he made it work by not using indices at all!</p>
  
  <p>In his JSP page he had:</p>
  
  <pre><code>&lt;input type="checkbox" name="contactNameList" value="someValue1"&gt;
  &lt;input type="checkbox" name="contactNameList" value="someValue2"&gt;
  &lt;input type="checkbox" name="contactNameList" value="someValue3"&gt;
  &lt;input type="checkbox" name="contactNameList" value="someValue4"&gt;
  </code></pre>
  
  <p>In his action class he had the 'appropiate' setters:</p>
  
  <pre><code>public List&lt;String&gt; getContactNameList()
  
  public void setContactNameList(List&lt;String&gt; list)
  </code></pre>
  
  <p>I'm baffled as to why this work. I <strong><em>think</em></strong> this works because he is sending non-bean data (in this case strings) and there is an intelligence build into Struts2/OGNL to append values to lists rather than overwrite them.</p>
  
  <p>Can anybody explain with great detail what is going behind the hood in this "no indices" case? How is the list of strings instantiated and populated with the snippets above?</p>