title: How to send array values to servlet using NameValuePair?
body: <p>I am trying to send array of boolean values to servlet.
  This is what I have done so far, and I am so stuck:</p>
  
  <pre><code>HttpClient client = new DefaultHttpClient();  
      String postURL = "http://APP_NAME.appspot.com/listenforrestclient";
      HttpPost post = new HttpPost(postURL);
          List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
  
          for (int i=0; i&lt;arrBool.length; i++) {
          arrBool[i] = r.nextBoolean();
          String[] user = {"","","","","",""};
          if (arrBool[i] == true) {
              params.add(new BasicNameValuePair("user[i]", arrBool.toString()));
          }
          else if (arrBool[i] == false) {
              params.add(new BasicNameValuePair("user[i]", arrBool.toString()));
      }
          }
          UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params,HTTP.UTF_8);
          post.setEntity(ent);
          HttpResponse responsePOST = client.execute(post);  
          HttpEntity resEntity = responsePOST.getEntity();  
          if (resEntity != null) {    
              System.out.printf("RESPONSE: ", EntityUtils.toString(resEntity));
          }
  } catch (Exception e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>I tried to do just user[i], "user[i]", user. Still couldn't find it.</p>
  
  <p>and on servlet I have:</p>
  
  <pre><code> public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException 
  {
      resp.setContentType("text/plain");
  
      for (int i=0; i&lt;mmaa.length; i++) {
          mmaa = req.getParameterValues("user");
          resp.getWriter().println(mmaa[i]);
      }
  </code></pre>
  
  <p>}</p>
  
  <p>I searched online a lot, couldn't find anything appropriate. I would really appreciate if someone would help me with this.</p>
  
  <p>Thanks</p>