Hithere.
I am trying to perform a GET against a URL using DefaultHttpClient of Apache's HTTPClient library.
Here is my code:
public String getHTML(String url) throws IOException, ClientProtocolException {
DefaultHttpClient httpclient = new DefaultHttpClient();
try {
HttpHost targetHost = new HttpHost(url);
HttpGet httpGet = new HttpGet("/");
HttpResponse response = httpclient.execute(targetHost, httpGet);
HttpEntity entity = response.getEntity();
If I pass a URL such as "www.google.ie", I have no problems. However, if I use a URL with a relative path such as "www.google.ie/intl/en/ads/", it fails. I get an UnknownHostException thrown from the httpclient.execute()
method above. It only happens with relative URLs and I'm not sure why. Has anyone any input as to why? Many thanks