I'm not using httpclient version 4, so I couldn't compile your code, but
it seems to me your confusing two different types of parameters.
The parameter you want are the URL parameters. To send them simply add
your data to the URL you create (taking care to put "?" before the first
parameter and "&" before subsequent parameters). For example:
HttpUriRequest httpGet = new
HttpGet("http://www.someserver.com/servlet?parm1=value1&parm2=value2&par
m3=value3");
I believe the parameters you set in the code below (I could be wrong,
since I don't have access to the code) are HTTP Connection Parameters,
which are parameters that are passed on the HTTP connection (e.g.
"host", "user-agent", etc.) and can be seen by sniffing the traffic
(using WireShark, or tcpdump, for example).
Please also note that parameters in the request must be escaped, i.e.
you must replaced any special characters (e.g. %) with an escaping
sequence, so that the parser won't confuse them with the special
character's function (see
http://www.blooberry.com/indexdot/html/topics/urlencoding.htm)
HTH,
Oz
-----Original Message-----
From: Kevin Roll [mailto:[email protected]]
Sent: Thursday, July 02, 2009 4:40 PM
To: [email protected]
Subject: Request parameters?
I'm trying to use httpclient-4.0-beta2 to achieve what seems like a
simple thing. I want to make a request to a certain URL with a set of
parameters. My code looks like this:
HttpParams params = new BasicHttpParams();
params.setParameter("someparam", "somevalue");
HttpClient httpClient = new DefaultHttpClient();
HttpUriRequest httpGet = new HttpGet("http://www.someserver.com/
servlet");
httpGet.setParams(params);
HttpResponse response = httpClient.execute(httpGet);
So, I would expect that a URL would be generated that looks like
http://www.someserver/com/servlet?someparam=somevalue
No matter what I do it seems that my parameters are ignored, causing
an error response from the server. Surprisingly none of the examples
cover this simple case. Am I doing something obviously wrong here?
Thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]