Click to See Complete Forum and Search --> : How to use Java with MS Proxy Server


Johnathan Day
September 19th, 2000, 02:30 PM
I am trying to get my application to connect to
the WWW thru Microsoft Proxy Server 2.0, but can't
get beyond the firewall. The following is the
relevant code snippet. Any suggestions...I'm
going bonkers!!!

Properties prop = System.getProperties();
prop.put("proxySet", "true" );
prop.put("proxyHost","name.of.proxy.server");
prop.put("proxyPort","80");
String password = "userid:password";
String encodedPassword = "Basic " + Codecs.base64Encode( password.getBytes() );
URL url = new URL("http://www.netscape.com/");
URLConnection connection = url.openConnection();
connection.setRequestProperty( "Proxy-Authorization",encodedPassword );
connection.setRequestProperty( "Proxy-Authentication",encodedPassword );
connection.setDoInput( true );
bfr = new BufferedReader(new InputStreamReader(connection.getInputStream()));