Forums Register Login

proxy server

+Pie Number of slices to send: Send
I am trying to connect to a webserver that uses a proxy server.

Tried the code below but keep geting the server error 407
the substitute the0.0.0.0 with the server ip address and username assword for my username and password

url = new URL("http://0.0.0.0/test/" + filename);
URLConnection connection = url.openConnection();
String password = "username assword";
String encodedPassword = b64c.encode(password);
connection.setRequestProperty( "Proxy-Authorization", encodedPassword);


InputStream is = url.openStream();


BufferedReader br = new BufferedReader(new InputStreamReader(is));
while( (record=br.readLine()) != null ) {
System.out.println(record);
}
is.close();
}
+Pie Number of slices to send: Send
Hi Felipe

You should try,
System.setProperty("http.proxyHost", "yourproxyserver.yourdomain.com");
System.setProperty("http.proxyPort", "yourproxyport");

Here is the link from sun forum,
http://forum.java.sun.com/thread.jspa?threadID=640068&tstart=135

The only issue with this is- it sets proxy in JVM System Property hence it ends up applying to ALL requests made after this setting..So you will have to remember to remove those property when done..

Regards
Maulin
Paper jam tastes about as you would expect. Try some on this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 928 times.
Similar Threads
https URLConnection
URLConnection Doubts -- Urgent!!
Socket connection from behind the Proxy Server
how to use make HTTP request behind a proxy server
Swing Browser Extension
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 04:57:52.