title: Get all checked checkbox values to servlet from dynamically generated JSP table?
body: <p>I'm displaying the results of my query from <code>Table A</code> in my results.jsp as goes:</p>
  
  <pre><code>&lt;form action="InsertToTableB" method="post"&gt;
         &lt;table&gt;
              &lt;tr&gt;
                  &lt;th&gt;Select&lt;/th&gt;
                  &lt;th&gt;First Name&lt;/th&gt;
                  &lt;th&gt;Last Name&lt;/th&gt;
                  &lt;th&gt;Email&lt;/th&gt;
              &lt;/tr&gt;
  
              &lt;c:forEach var="user" items="${resultData}"&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;input type="checkbox" name="selected" value="&lt;c:out value='${user.userID }' /&gt;"/&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;c:out value="${user.fName }"/&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;c:out value="${user.lName }"/&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;c:out value="${user.email }"/&gt;&lt;/td&gt;    
              &lt;/tr&gt;
              &lt;/c:forEach&gt;    
          &lt;/table&gt;
     &lt;button type="submit" value="Submit"&gt;Insert to Table B&lt;/button&gt;
     &lt;button type="submit" value="Submit"&gt;Delete from Table A&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And this <code>form</code> is being passed into my <code>InsertToTableB</code> servlet.</p>
  
  <p>How do I get ONLY the selected values from the generated table <code>&lt;input type="checkbox" name="selected" value="&lt;c:out value='${user.userID }' /&gt;"/&gt;</code>and
  how do I know which button (<code>Insert to Table B</code> or <code>Delete from Table A</code>) has been pressed?</p>
  
  <p>I've only worked with <code>&lt;input type="text"&gt;</code> and getting the value into the servlet using <code>.getParameter('name')</code> and those are <code>Strings</code>.</p>
  
  <p>Is it the same for <code>checkbox</code> input type?</p>
  
  <p>Can I have 2 or more submit buttons in a form each with a different function?</p>
  
  <p>A picture of my table with sample data:</p>
  
  <p><a href="https://i.stack.imgur.com/tIJzj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tIJzj.jpg" alt="enter image description here"></a></p>