tags:

views:

97

answers:

2

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?

+7  A: 

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.

Clint
Yeap... That's the right library for the work
OscarRyz
+2  A: 

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.

David Zaslavsky