commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amir D. Kolsky" <a...@kolsky.com>
Subject RE: HttpClient throwing UnknownHostException
Date Wed, 24 Apr 2002 10:10:01 GMT
Remove the http:// from the URL

-----Original Message-----
From: Allistair Crossley [mailto:a.crossley@obvious.uk.com]
Sent: Wed, April 24, 2002 1:06 PM
To: commons-dev@jakarta.apache.org
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 postmaster@obvious.uk.com. Thank you.



--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message