Wrox Home  
Search P2P Archive for: Go

  Return to Index  

servlets thread: Reading behind proxy?


Message #1 by "Low Kok Leong" <lousai@t...> on Fri, 8 Dec 2000 12:16:43 -0000
Hei Kok Leong,

u can read behind the proxy by put this codes in ur servlet, before u open
the url connection to the page u want, with the "ProxyHost" & "ProxyPort"
num as parameter.

System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost",ProxyHost );
System.getProperties().put("proxyPort",ProxyPort );

----- Original Message -----
From: "Low Kok Leong" <lousai@t...>
To: "Servlets" <servlets@p...>
Sent: Friday, December 08, 2000 8:16 PM
Subject: [servlets] Reading behind proxy?


> Is this the correct syntax from command line to read url content.
> java -Dhttp.proxyHost=proxyhost
>     [-Dhttp.proxyPort=portNumber] URLReader
>
> ---------------below sample code from sun------------------------
> import java.net.*;
> import java.io.*;
>
> public class URLReader {
>     public static void main(String[] args) throws Exception {
> URL yahoo = new URL("http://www.yahoo.com/");
> BufferedReader in = new BufferedReader(
> new InputStreamReader(
> yahoo.openStream()));
>
> String inputLine;
>
> while ((inputLine = in.readLine()) != null)
>     System.out.println(inputLine);
>
> in.close();
>     }
> }
>
> -----------------------------end code--------------------------------

  Return to Index