hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "hefeng" <hef.onl...@gmail.com>
Subject RE: how to set parameters in doGet method
Date Wed, 17 Oct 2007 01:18:45 GMT
Similar with posting a form in PostMethod, you can use the NameValuePair[]
to hold the parameters and set the parameters with
HttpMethodBase#setQueryString(NameValuePair[] params).

-----Original Message-----
From: Ashish Kulkarni [mailto:ashish.kulkarni13@gmail.com] 
Sent: Wednesday, October 17, 2007 2:46 AM
To: httpclient-user@jakarta.apache.org
Subject: how to set parameters in doGet method

Hi
Suppose i have an URL http://myhost:8080/myServlet?test=abc&test1=klm

Now i need to set parameters test and test1,
the code i have is

HttpClient client = new HttpClient();
GetMethod method = new GetMethod("http://myhost:8080/myServlet");
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,new
DefaultHttpMethodRetryHandler(3, false));
int statusCode = client.executeMethod(method);
if (statusCode != HttpStatus.SC_OK) {
System.err.println("Method failed: " + method.getStatusLine());
}
InputStream is =method.getResponseBodyAsStream();


Now how do i add test and test1 parameters to be passed to the URL

Ashish


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Mime
View raw message