Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

proxy, http.proxyHost doesn't work

Thread view: 
Robert M. Gary - 10 Nov 2006 08:07 GMT
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
EJP - 11 Nov 2006 00:34 GMT
> 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, ...
Arne Vajhøj - 11 Nov 2006 01:03 GMT
>     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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.