hi,
i use the code below to retrieve and print the code of a page from a java program. Tried to use it in a servlet (site mycgiserver.com) but it didn�t work (stream closed). Then i tried the second piece of code below and it didn�t work, too (no errors, but i got no strings printed).
Well, i new to java and newer to servlets, but it does not seems to be a big problem. Can anyone help me.
Thanks.
Tom sp.
_________________________________________________________________________
URL url = new java.net.URL("http://www.yahoo.com");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String entrada;
while ((entrada = in.readLine()) != null) {
System.out.println(entrada);
in.close();
}
_________________________________________________________________________
_________________________________________________________________________
String entrada;
URL url = new URL("http://www.yahoo.com");
URLConnection con = url.openConnection();
con.connect();
DataInputStream in = new DataInputStream(con.getInputStream());
while ((entrada = in.readLine()) != null) {
System.out.println(entrada);
}
_________________________________________________________________________
