импорт осуществляется из библиотек org.apache.http

ользую Apache HTTP Client, и мне нужно отправить запрос POST моему сервлету. При отправке запроса мой сервлет не получает никаких параметров (вHttpServletRequest).

Вот код клиентской программы:

// 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();
}

Как правильно установить параметры запроса POST, чтобы сервлет действительно их получал?

Ответы на вопрос(3)

Ваш ответ на вопрос