title: Getting all selected checkboxes values using ajax and jsp/servlets?
body: <p>I'm developing a jsp/serlvet application. I have a page with a list of inputs as checkboxes . I want to send values of selected buttons to a servlet using ajax/jquery. In the servlet , I want to extract these values and use them .<br>
  <strong>for example:</strong>  </p>
  
  <ul>
  <li>The user checks some checkboxes , for example, list of messages.  </li>
  <li>He/She presses Delete <strong>Link</strong> to delete selected messages.</li>
  </ul>
  
  <p>I searched and found something like this :</p>
  
  <pre><code>$("#inboxDeleteSelected").click(function(){
      var data = { 'checkBoxList[]' : []};
      var list=$(":input:checkbox:checked"); // getting all selected checkboxes.
      $(list.each(function() {
         data['checkBoxList[]'].push($(this).val());
      }));
      $.post("servlet?do=deleteSelected",data,function(d){
          // do something here
      });
  });
  </code></pre>
  
  <p><strong>My questions:</strong>  </p>
  
  <ul>
  <li>How can I send selected checkboxes values to a servlet ?</li>
  <li>How can I extract these values in the servlet ?</li>
  </ul>
  
  <p><strong>Note:</strong>  </p>
  
  <p>I don't use submit button to submit the selected checkboxes,Indeed I use link/anchor to send those values .</p>