You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christian Wernet <c_...@hotmail.com> on 2001/03/08 21:24:06 UTC

executing a http request within a tomcat servlet

bon giorno,

i'm in a doGet method of a servlet and want to switch into a http-client for 
a moment (doing a get or a post),  before handle back the received stuff to 
my original client.

i did like this:

HttpURLConnection theHttpConnection = null;
try{
  URL url = new URL("http://www.apache.org");
  HttpURLConnection con = (HttpURLConnection)url.openConnection();
  InputStream is = con.getInputStream();
}
catch (IOException  ex) {
  ex.printStackTrace();
}

and now the result:

java.net.UnknownHostException: www.apache.org
  at java.net.InetAddress.getAllByName0(InetAddress.java:571)
  at java.net.InetAddress.getAllByName0(InetAddress.java:540)
  at java.net.InetAddress.getByName(InetAddress.java:449)
  [...]

if i hand in a local url, for example the url of another servlet on my local 
tomcat, i get:

java.io.FileNotFoundException:
http://127.0.0.1:8080/foo/servlet/FunkyServlet?ID=0741825

who can explain and improve?

thank you so much!

carl




_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, email: tomcat-user-help@jakarta.apache.org