Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I need your Help!!! -- How to Access protected Web page/Image file?

 
Sharp Tan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I try to access same web pages and image files from a potal. Someone suggested me to use "Authenticator" class. I create a subclass named "myAuthenticator" as following:
class myAuthenticator extends Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
System.out.println("Password needed");
return new PasswordAuthentication("myid", "pw".toCharArray());
}
}
Before I create a URLConnection I call
Authenticator.setDefault(new myAuthenticator);
I try to access "http://mail.yahoo.com" and my own potal. It doesn't work. What I get is still the login page.
Who know the reason? Anybody has solution to solve my problem?
I'm very thankful for your help!
Sharp
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic