Skip to main content

Using URL to connect via a proxy.

1 reply [Last post]
byhisdeeds
Offline
Joined: 2006-01-06
Points: 0

Does anyone know if there are any issues regarding using URL to access data via a proxy within a .jnlp application.

I set the system properties:

Properties p = System.getProperties();
p.put("proxySet", "true");
p.put("proxyHost", "my.host.org");
p.put("proxyPort", "8080");

then I use the URL class to read some data.

URL url = new URL("http://some.web.address/path/to/some/file");
BufferedInputStream bis = new BufferedInputStream(url.openStream());
....
....

However I cannot get it to work. I know the proxy.

Can anyone see anything that I am missing.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
andyherrick
Offline
Joined: 2005-04-17
Points: 0

Depends on the version of Java you are using.
for Java 1.4 the system properties "http.proxyPort" and "http.proxyHost" are used.
for java 1.5.0 and beyond, the deployment products (Java Web Start and Java Plug-in) use the new ProxySelector and Proxy classes in java.net to install a ProxySelector that can dynamically select proxies based on the url.
If you want the System Properties to still be used you need to call
ProxySelector.setDefault(null);

/Andy