• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Programatically call Java 2 secured page

 
Adam Kreiss
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

Not positive this is the right forum but here it goes.

Does anyone have a good tutorial for accessing a web page via Java code where the page is secured with standard Java 2 security by the web server? Ideally I'd like to use Apache HttpClient to do so but haven't been able to find any good examples.

Thanks in advance
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "secured with standard Java 2 security"? The only security that would be applicable to a web app would be to use HTTP Authentication (and possibly using HTTPS, which doesn't have much to do with Java). HttpClient can handle HTTP Authentication.
 
Adam Kreiss
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the confusion.

I'm thinking about the j_username/j_password user auth functionality that most web servers offer. How would I go about passing the auth values in a request to the server?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, that's called FORM authentication, and is a little harder to automate. The code would access some URL that is protected, which would then cause the login page to be shown. Into that page (or rather, the HTML form in it) would the code enter appropriate values for j_username and j_password, and then submit it. If everything went OK, the server would then respond with the page that was originally requested.
This discussion may help.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic