Java Login to SSL Website

Please help me download a page from behind a secure site with username and password authentication and post method.  Specifically, I would like to download from under fantasy football.  I am using Apache HttpClient, so it would be real nice if answers used that.  My problem has something to do with cookies.  The error message is that the cookie has been rejected.  Even though I am using Java, and my email address appears no where in the Java code, the rejected cookies contain my email address.   So I am wondering whether the Java code is accessing my IE cookies.  I have tried all of the cookie policies.

public static void main(String[] args) throws HttpException, IOException {
String fanUrlStr = "";
HttpClient c = new HttpClient();
c.getParams().setParameter("http.protocol.single-cookie-header", true);
PostMethod p = new PostMethod(fanUrlStr);
p.addParameter("username", "a_user");
p.addParameter("password", "some_passwod");
String response = p.getResponseBodyAsString();
FileWriter fw = new FileWriter(new File("C:/out.html"));

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I do not see you even attempting to login there... so if this is a login based site, you need to login using the HttpClient before you do anything else.

Something like this should be enough in most cases.

Unless if they use form login, in which case you need something like this:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ff10Author Commented:
solution was not complete
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.