title: Java ArrayList into Name value pair
body: <p>In a java class, am using an  arraylist say reports containing  list of all the reports which have reportid, reportname, reporttype etc which i want to add into NameValuePair and send a Http postmethod call to a particular url.</p>
  
  <p>I want to add the arraylists - reportname  into name value pair(org.apache.commons.httpclient.NameValuePair) and then use the http client post method to submit the name value pair data to a particular url.</p>
  
  <p>Here is my name value pair</p>
  
  <pre><code>if (validateRequest()) {
          NameValuePair[] data = {
              new NameValuePair("first_name", firstName),
              new NameValuePair("last_name", lastName),
              new NameValuePair("email", mvrUser.getEmail()),
              new NameValuePair("organization", mvrUser.getOrganization()),
              new NameValuePair("phone", mvrUser.getPhone()),
              new NameValuePair("website", mvrUser.getWebsite()),
              new NameValuePair("city", mvrUser.getCity()),
              new NameValuePair("state", mvrUser.getState()),
              new NameValuePair("country", mvrUser.getCountry()),
              new NameValuePair(**"report(s)", reports**.)
          };
  </code></pre>
  
  <p>please suggest me how to add the reports arraylist reportname into reports field of NameValuePair.</p>
  
  <p>--
  thanks</p>
  
  <p>@ adarsh
  can I use with generics something like this?</p>
  
  <pre><code>reportname = "";
  for (GSReport report : reports) {
          reportname = reportname + report.getReportName();
          reportname += ",";
      }
  </code></pre>
  
  <p>and then add in namevalue pair as </p>
  
  <pre><code>new NameValuePair("report(s)", reportname)
  </code></pre>