/ Published in: Java
Required libraries: http://hc.apache.org/downloads.cgi
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
package yourpackage; import java.io.IOException; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpVersion; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.CoreProtocolPNames; public class HttpClientGetTest { get(); } HttpClient httpclient = new DefaultHttpClient(); httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); HttpGet get = new HttpGet("your-url"); HttpResponse response = httpclient.execute(get); HttpEntity resEntity = response.getEntity(); int returnCode = response.getStatusLine().getStatusCode(); } }