On Tue, Oct 10, 2000 at 02:57:04PM -0400, Norr, Peter wrote:
> How do I open a URL connection to a site that has basic authentication on?
>
> I have the user name and password!!
>
> Pete

Hi Pete,

you have to pass required parameters like this :

    String userPassword = "youruser" + ":" + "yourpass";
    String encoding = new sun.misc.BASE64Encoder().encode (userPassword.getBytes());
    URLConnection connection;
    URL url = new URL ("http://your.url.that.requires.authorization.com");
    connection = url.openConnection ();
    connection.setDoOutput (true);
    connection.setAllowUserInteraction (true);
    connection.setRequestProperty ("Authorization", "Basic " + encoding);

    and so on.... depending what you want to do.

Regards,

Ivo.

Ultra d.o.o.
Zadar, Croatia

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to