esuslogo
 [To advertise Java(tm) Events here, contact joris@esus.com!]
banner

Java™
by example!






New @ Esus.com


  gb  In-house search engine for better results!

  gb  Get updates with the esus.com
newsletter!









  Home 
 Browse Categories 
 Ask a Java Question 
 Help 
  For Java Tips & Tricks, subscribe to the esus.com newsletter!
Search Java Q&A, Links, API's:   adv 

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:

This code sample is only viewable to esus.com members
Login or become a member!

In source:

This code sample is only viewable to esus.com members
Login or become a member!



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:

This code sample is only viewable to esus.com members
Login or become a member!




Further Information
Author of answer: Joris Van den Bogaert

Comments
Comments to this answer are only viewable by members. Login or become a member!





Terms of Service | Privacy Policy | Contact

Copyright © 2000-2003 Esus.com - All Rights Reserved 
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. Esus.com is independent of Sun Microsystems, Inc. All other trademarks are the sole property of their respective owners.