title: Apache HTTP Client, POST request. How to correctly set request parameters?
body: <p>I'm using Apache HTTP Client and I need to send a POST request to my servlet.
  When the request is sent my servlet does not receive any parameters (in the <code>HttpServletRequest</code>).</p>
  
  <p>Here is the client program code:</p>
  
  <pre><code>// Engage the HTTP client
  DefaultHttpClient httpclient = new DefaultHttpClient();
  HttpResponse response;
  try {
      HttpPost httpPost = new HttpPost("http://localhost:8080/test-json-web/JSONReceiverServlet");
  
      // Setup the request parameters
      HttpParams params = new BasicHttpParams();
      params.setParameter("taskdef", task1JsonString);
      httpPost.setParams(params);
  
      // Make the request
      response = httpclient.execute(httpPost);
  
      HttpEntity responseEntity = response.getEntity();
  
      System.out.println("----------------------------------------");
      System.out.println(response.getStatusLine());
      if(responseEntity != null) {
          System.out.println("Response content length: " + responseEntity.getContentLength());
      }
  
      String jsonResultString = EntityUtils.toString(responseEntity);
      EntityUtils.consume(responseEntity);
      System.out.println("----------------------------------------");
      System.out.println("result:");
      System.out.println();
  } catch (ClientProtocolException e) {
      e.printStackTrace();
  } catch (IOException e) {
      e.printStackTrace();
  } finally {
      httpclient.getConnectionManager().shutdown();
  }</code></pre>
  
  <p>How to correctly set POST request parameters so that servlet actually receives them?</p>