You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Chris Brown <ch...@hotmail.com> on 2004/10/22 10:18:12 UTC

Auto-detecting proxy settings in a standalone Java app

Hello,

I would like to perform a simple request against a HTTP server in an 
application that will be deployed to customers with a wide variety of 
network configurations.  The application won't be deployed as an applet or 
within Java Webstart, but will require JDK 1.4.2+ as the platform.  The 
target audience are all Windows users.

I've searched the HTTPClient archives and also the forums on Sun's Java 
Developer site.  The only useful links were:

http://forum.java.sun.com/thread.jsp?forum=30&thread=364342
http://www.mail-archive.com/commons-httpclient-dev@jakarta.apache.org/msg05349.html

I get the following error when trying this out:

java.io.IOException: Proxy service provider is not yet set
at com.sun.java.browser.net.ProxyService.getProxyInfo(ProxyService.java:40)

...so I assume this only works within Webstart or an applet.

Is there any way I can *automatically* retrieve the user's browser settings, 
even if requires using JNI or JNIWrapper for example ?  At least the proxy 
host and port, even better if it can automatically enable login (or even 
provide me with enough info to use the NTLM features of HTTPClient, if 
required by the customer's environment).

Manual proxy configuration generates *way* more support costs at present 
than anything else in the project.  It's annoying to be disadvantaged in 
this way, when most native Windows applications "just work"...

Thanks in advance,
Chris Brown

_________________________________________________________________
Bloquez les fenêtres pop-up, c'est gratuit ! http://toolbar.msn.fr


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Re: Auto-detecting proxy settings in a standalone Java app

Posted by Oleg Kalnichevski <ol...@bearingpoint.com>.
And how often does that happen in a course of one working day? I'd say
not that often. I do agree with Roland that a startup script written in
VBScript appears to be the best solution for the problem

Oleg

On Fri, 2004-10-22 at 10:54, Ortwin Glück wrote:
> Roland Weber wrote:
> > Wait, here is another idea: you could write a startup script that does
> > the proxy settings lookup, then passes the settings through -D
> > definitions as system properties, which can be accessed by your
> > Java application. That's a bit less ugly than calling native code
> > from within the app. The proxy settings for the HttpURLConnection
> > of the JDK are expected as system properties, too.
>
> Of course that implies you need to restart your app, everytime the proxy
> settings change...
>
> Odi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org

***************************************************************************************************
The information in this email is confidential and may be legally privileged.  Access to this email by anyone other than the intended addressee is unauthorized.  If you are not the intended recipient of this message, any review, disclosure, copying, distribution, retention, or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful.  If you are not the intended recipient, please reply to or forward a copy of this message to the sender and delete the message, any attachments, and any copies thereof from your system.
***************************************************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Re: Auto-detecting proxy settings in a standalone Java app

Posted by Ortwin Glück <or...@nose.ch>.

Roland Weber wrote:
> Wait, here is another idea: you could write a startup script that does
> the proxy settings lookup, then passes the settings through -D
> definitions as system properties, which can be accessed by your
> Java application. That's a bit less ugly than calling native code
> from within the app. The proxy settings for the HttpURLConnection
> of the JDK are expected as system properties, too.

Of course that implies you need to restart your app, everytime the proxy 
settings change...

Odi

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Re: Auto-detecting proxy settings in a standalone Java app

Posted by Roland Weber <RO...@de.ibm.com>.
Hello Chris,

native Windows applications "just work" because they access native
Windows APIs to read the proxy settings, which are probably stored
somewhere in the Windows registry. Browsers and the Java Plugin
for browsers are native Windows applications, and therefore can do
just that.

The only solution I can imagine right now is for you to write JNI code
that looks up the appropriate keys in the registry. Which means you'll
have to distribute a DLL along with the Java application.

Wait, here is another idea: you could write a startup script that does
the proxy settings lookup, then passes the settings through -D
definitions as system properties, which can be accessed by your
Java application. That's a bit less ugly than calling native code
from within the app. The proxy settings for the HttpURLConnection
of the JDK are expected as system properties, too.

hope that helps,
  Roland





"Chris Brown" <ch...@hotmail.com> 
22.10.2004 10:18
Please respond to
"Commons HttpClient Project"


To
commons-httpclient-dev@jakarta.apache.org
cc

Subject
Auto-detecting proxy settings in a standalone Java app






Hello,

I would like to perform a simple request against a HTTP server in an 
application that will be deployed to customers with a wide variety of 
network configurations.  The application won't be deployed as an applet or 

within Java Webstart, but will require JDK 1.4.2+ as the platform.  The 
target audience are all Windows users.

I've searched the HTTPClient archives and also the forums on Sun's Java 
Developer site.  The only useful links were:

http://forum.java.sun.com/thread.jsp?forum=30&thread=364342
http://www.mail-archive.com/commons-httpclient-dev@jakarta.apache.org/msg05349.html


I get the following error when trying this out:

java.io.IOException: Proxy service provider is not yet set
at 
com.sun.java.browser.net.ProxyService.getProxyInfo(ProxyService.java:40)

...so I assume this only works within Webstart or an applet.

Is there any way I can *automatically* retrieve the user's browser 
settings, 
even if requires using JNI or JNIWrapper for example ?  At least the proxy 

host and port, even better if it can automatically enable login (or even 
provide me with enough info to use the NTLM features of HTTPClient, if 
required by the customer's environment).

Manual proxy configuration generates *way* more support costs at present 
than anything else in the project.  It's annoying to be disadvantaged in 
this way, when most native Windows applications "just work"...

Thanks in advance,
Chris Brown

_________________________________________________________________
Bloquez les fenêtres pop-up, c'est gratuit ! http://toolbar.msn.fr


---------------------------------------------------------------------
To unsubscribe, e-mail: 
commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: 
commons-httpclient-dev-help@jakarta.apache.org