When using a URLConnection, how do I send a user name and password to access a password-protected URL?

Tim Rohaly

There are two articles on the JavaWorld site which address this question in detail. The first, http://www.javaworld.com/javaworld/javatips/jw-javatip46.html, shows a solution using the Authenticator class available in Java 2. The second, http://www.javaworld.com/javaworld/javatips/jw-javatip47.html, provides a solution which can run under JDK 1.1.