title: Using multiple parameters from an array in a servlet
body: <p>Here is the HTML from my .jsp page:</p>
  
  <pre><code>&lt;tr&gt;
    &lt;td&gt;&lt;input type="checkbox" name=&lt;%=editID%&gt;COM /&gt; &lt;/td&gt;    
    &lt;td&gt;blah blah&lt;/td&gt;
    &lt;td&gt;blah blah&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>So here the user will select checkboxes and submit them to be deleted.  But I want them to be able to select multiple checkboxes.  For instance, if they chose two checkboxes, say #'s 5 and 6, it will come to the servlet as 5COM and 6COM (this is due to bad table design). So next, I am trying to get multiple parameters from my jsp page, and write them to my database in my servlet.  Here are my definitions:</p>
  
  <pre><code>  String[] comEdit = request.getParameterValues("editIDCom");   
    String comEditDel = "";
    int[] comEditDels = null;
  </code></pre>
  
  <p>So using the above example, the comEdit array should contain 5COM and 6COM....Next, I am trying to get the substring of every item in the array 'comEdit' and then I am trying to put it into a int Array: </p>
  
  <pre><code>  for (int i = 0; i &lt; comEdit.length; ++i) {
        String com = comEdit[i];
        comEditDel = com.substring(0, com.length() - 3);    
        comEditDels = new int[comEditDel == null ? 0: comEditDel.length];
        comEditDels[i] = Integer.parseInt(comEditDel[i]);
    }
  </code></pre>
  
  <p>So sticking with the same example, I am trying to make a new int Array that will give me [5, 6]....Now the above part is most likely incorrect, but I gave it a shot, and you can see my intentions.  Here I am trying to use the array in my callable statement:</p>
  
  <pre><code>    CallableStatement stmt = null;
      PreparedStatement pstmt = null;
      Connection conn = null;
      ArrayDescriptor ad = null;
      String dSource = getServletContext().getInitParameter("dataSource");
  
     stmt = conn.prepareCall("{?= call My_function(?)}");
     stmt.registerOutParameter(1, Types.INTEGER);
     ad = ArrayDescriptor.createDescriptor("NUM_ARRAY", conn);
     stmt.setArray(2,new ARRAY(ad, conn, comeditDels));
  </code></pre>
  
  <p>So again, using the example, the stmt.setArray function should send the array [5,6] to My_function. Again this is my attempt, and it is prob incorrect?  Any help is appreciated.  Thanks!</p>