|
Java™ by example!
|
|
|
How do I connect to the net through a proxy server?
An applet will automatically use the browser settings. With an application, the proxy server can be specified with the following properties: proxySet, proxyHost and proxyPort. They can either be set at the command line or in the source. At command line:
In source:
It could be that the proxy server requires you to authenticate with a username + password. This request has to be in the form "username:password" encoded in base64. A converter to base64 can be found in the package sun.misc - BASE64Encoder. The final call is to setRequestProperty which will change the http header as to get you through the proxy. Code snippet:
Further Information
Author of answer: Joris Van den Bogaert
Comments
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|