Remove the http:// from the URL -----Original Message----- From: Allistair Crossley [mailto:[EMAIL PROTECTED]] Sent: Wed, April 24, 2002 1:06 PM To: [EMAIL PROTECTED] Subject: HttpClient throwing UnknownHostException
I have just started to use HttpClient. The code compiles fine and I have used the test cases as guidance. However, my code throws an UnknownHostException and I am not sure why. I have tested this with the jakarta host and port 80 but it does not work. I am on a LAN so there is a connection. I attach my code here import java.io.*; import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.methods.GetMethod; public class HTTPPoster2 extends Thread { public HTTPPoster2() { start(); } public void run() { System.out.println("HTTPPoster Started"); try { Thread.sleep(2000); } catch(InterruptedException iE) { ; } try { GetMethod httpGet = new GetMethod(); HttpClient httpClient = new HttpClient(); httpClient.startSession("http://jakarta.apache.org", 80); httpClient.executeMethod(httpGet); httpClient.endSession(); System.out.println("Response: " + httpGet.getResponseBodyAsString()); } catch(IOException ioE) { System.out.println("HTTPPoster IOException: " + ioE); } catch(HttpException ioE) { System.out.println("HTTPPoster HttpException: " + ioE); } catch(IllegalStateException isE) { System.out.println("HTTPPoster IllegalStateException: " + isE); } System.out.println("HTTPPoster Ended"); } } Allistair Crossley Lead Technical Developer Obvious Solutions (Global) Ltd. "Delivering the vision for a mobile lifestyle" www.obvioussolutions.co.uk (m) +44 (0) 7884 056 274 (w) +44 (0) 20 8451 9352 (f) +44 (0) 20 8537 5236 /******************************************/ This is an email from Obvious Solutions (Global) Ltd. The contents of this email are confidential to the ordinary user of the email address to which it was addressed. No-one else may copy or forward all or any of it in any form. If you receive this email in error, we should be obliged if you would telephone our postmaster on +44 (0)208 357 8352 or email [EMAIL PROTECTED] Thank you. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>