Friday, April 8, 2011

How do I "log in" to a web app and access subsequent pages using Java?

I want to write a Java program that'll access a few web pages that requires logging in. How would I keep the session cookie resulting from logging in so I can access those pages?

From stackoverflow
  • Commons HTTPClient has all the capability to do what you want. You can do any sort of authentication and cookie handling that you need. Here is the code for the CookieDemoApp.

    OscarRyz : Yeap... That's the right library for the work
  • You'll probably want to use CookieManager (you could also look at its superclass CookieHandler). I don't know whether the standard URLConnection class will automatically store cookies for you, though.

0 comments:

Post a Comment