proxy, http.proxyHost doesn't work

R

Robert M. Gary

I have been fighting with proxy issues for some time and finally solved
it. Originally I was doing the following...
String url = "http://www.goodhost.com:80",
proxy = "64.202.165.130",
port = "3128";


URL server = new URL(url);

System.getProperties().put("http.proxySet","true");
System.getProperties().put("http.proxyHost",proxy);
System.getProperties().put("http.proxyPort",port);
HttpURLConnection conn = (
HttpURLConnection)server.openConnection();
conn.connect();

But the proxy was never used. I always got a security exception on
"www.goodhost.com" and changing the proxy to be invalid did not cause
any error. So I went down to the http level and it worked....
URL server = new URL(url);
Socket socket = new Socket(proxy,port);
Writer writer = new OutputStreamWriter(socket.getOutputStream(),
"US-ASCII");
writer.write("GET " + server.toExternalForm() + " HTTP/1.0\r\n");
writer.write("Host: " + server.getHost() + "\r\n\r\n");

So my question, is "Why doesn't the http.proxySet work? Why do I have
to manage the http myself? Im running java 1.5.0_07 in Tomcat. I would
really rather not do the HTTP myself.

-Robert
 
E

EJP

Robert said:
So my question, is "Why doesn't the http.proxySet work?

I think you have a wider problem but FYI that particular property has
never done anything in the JDK. It existed in the short-lived HotJava
bean and a number of well-meaning authors put it into their books. It
does nothing whether set true, false, blue, green, grue, ...
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Robert said:
System.getProperties().put("http.proxySet","true");
System.getProperties().put("http.proxyHost",proxy);
System.getProperties().put("http.proxyPort",port);
But the proxy was never used. I always got a security exception on
"www.goodhost.com" and changing the proxy to be invalid did not cause
any error.

System.setProperty("http.proxyHost", proxy);
System.setProperty("http.proxyPort", port);

has worked for me.

Does your proxy server requires authentication ?

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top