pokeRex110 pokeRex110 - 3 months ago 14
Java Question

Adding parameter to HttpPost on Apache's httpclient

I am trying to set some Http parameters in the HttpPost object.

HttpPost post=new HttpPost(url);
HttpParams params=new BasicHttpParams();
params.setParameter("param", "value");
HttpResponse response = client.execute(post);

It looks like the parameter is not set at all. Do you have any idea why this is happening?

Thank you

HttpPost httpPost = new HttpPost(url);
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("param", "value");
httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));