Note that there are some explanatory texts on larger screens.

plurals
  1. POClientWithResponseHandler example Gives an ERROR?
    text
    copied!<p>I've tried hard to solve this and I couldn't. I'm trying to use httpClient 4.1.2 from apache. As logic I started with the example, the problem is that I'm having some strange error that I don't understand. This is the deal:</p> <pre><code> package ClientWithResponseHandler; import org.apache.http.client.ResponseHandler; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.BasicResponseHandler; import org.apache.http.impl.client.DefaultHttpClient; public class Main { public final static void main(String[] args) throws Exception { HttpClient httpclient = new DefaultHttpClient(); try { HttpGet httpget = new HttpGet("http://www.google.com/"); System.out.println("executing request " + httpget.getURI()); // Create a response handler ResponseHandler&lt;String&gt; responseHandler = new BasicResponseHandler(); String responseBody = **httpclient.execute(httpget, responseHandler);** System.out.println("----------------------------------------"); System.out.println(responseBody); System.out.println("----------------------------------------"); } finally { // When HttpClient instance is no longer needed, // shut down the connection manager to ensure // immediate deallocation of all system resources httpclient.getConnectionManager().shutdown(); } } </code></pre> <p>}</p> <p>The error is with "httpclient.execute(httpget, responseHandler);" IT says that it cannot find the method execute(HttpGet,ResponseHandler) The question shouldn't the example work? What am I doing wrong?! :S</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload