title: Get selected rows from a html table using Servlets and JSP
body: <p>I have the next jsp file called <code>Bookstore.jsp</code>, in which I filled up a table with data from a database.</p>
  
  <pre><code>&lt;%
  ArrayList&lt;Book&gt; b = new ArrayList&lt;Book&gt;();
  b = SqlSentencesList.showCatalog(); // this method returns an arrayList with all books
  %&gt;
  
  &lt;form method="get" action="ShoppingCarController"&gt;
      &lt;table border="2"&gt;
          &lt;tr&gt;
              &lt;th&gt;ISBN&lt;/th&gt;
              &lt;th&gt;Title&lt;/th&gt;
              &lt;th&gt;Author&lt;/th&gt;
              &lt;th&gt;Price&lt;/th&gt;
              &lt;th&gt;Select&lt;/th&gt;
          &lt;/tr&gt;
  
          &lt;%for(int i=0; i&lt;l.size();i++){%&gt;
              &lt;tr&gt;
                  &lt;td&gt; &lt;%out.print(b.get(i).getIsbn());%&gt; &lt;/td&gt;
                  &lt;td&gt; &lt;%out.print(b.get(i).getTitle());%&gt; &lt;/td&gt;
                  &lt;td&gt; &lt;%out.print(b.get(i).getAuthor());%&gt; &lt;/td&gt;
                  &lt;td&gt; &lt;%out.print(b.get(i).getPrice());%&gt; &lt;/td&gt;
                  &lt;th&gt; &lt;input type="checkbox" name="checkboxGroup" value="&lt;%Integer.toString(i);%&gt;"/&gt; &lt;/th&gt;
              &lt;/tr&gt;
          &lt;% } %&gt;
      &lt;/table&gt;
      &lt;input type="submit" value="Add to shopping car"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Now, I need the same book data (ISBN, title, author and price) in the Servlet, but just from the ones selected.</p>
  
  <p>This's my doGet method from ShoppingCarController servlet:</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          ArrayList&lt;Book&gt; shoppingCar = new ArrayList&lt;Book&gt;();
  
          String[] values = request.getParameterValues("checkboxGroup");
  
          for(int i=0; i&lt;values.length; i++) {
              System.out.println(values[i]);
          }
      }
  </code></pre>
  
  <p>I tried to printed it to see what I'm getting, but nothing shows up in the console.</p>
  
  <p>I was looking at this similar case: <a href="https://stackoverflow.com/questions/4525230/how-to-pass-data-from-selected-rows-using-checkboxes-from-jsp-to-the-server">How to pass data from selected rows using checkboxes from JSP to the server</a> and I think my problem is with the <code>value</code> attributes, but I don't know the syntax used in that question, don't understand that <code>for each</code> and the <code>&lt;c:out</code> tags; in short, I don't know how to adapt my code to get it work.</p>
  
  <p>Someone give me a hand with that.</p>