views:

62

answers:

3
org.apache.http.client.methods.HttpGet;

HttpGet method = new HttpGet(url.toExternalForm());
method.getParams()

Whare are these params? Are they the query string? there seems to be no easy way to add a query string with org.apache.http.client.methods.HttpGet

+1  A: 

These parameters are the HTTP GET request parameters.

For instance in the URL http://www.mysite.com/login?username=mcjones, the parameter username has value mcjones.

Guillaume Alvarez
+2  A: 

According to the Http Client tutorial, you can do this:

List<NameValuePair> qparams = new ArrayList<NameValuePair>();
qparams.add(new BasicNameValuePair("q", "httpclient"));
qparams.add(new BasicNameValuePair("btnG", "Google Search"));
qparams.add(new BasicNameValuePair("aq", "f"));
qparams.add(new BasicNameValuePair("oq", null));
URI uri = URIUtils.createURI("http", "www.google.com", -1, "/search", 
    URLEncodedUtils.format(qparams, "UTF-8"), null);
HttpGet httpget = new HttpGet(uri);
Michael Borgwardt
A: 

From http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/HttpMethodBase.html#getParams%28%29 :

getParams

public HttpMethodParams getParams()

Returns HTTP protocol parameters associated with this method.

Specified by:
    getParams in interface HttpMethod

Returns:
    HTTP parameters.
Since:
    3.0
See Also:
    HttpMethodParams

The full list of parameters for the request can be found at http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/params/HttpMethodParams.html

Martin Eve