Jakarta.commons.httpclient session handling

I am using jakarta.commons.httpclient to login and perform some operations in a website.

Basically I need to login, and then perform 2 post requests.
However, since I am performing the requests one at a time, and although I can login the next requests get me redirected to a "Not logged in" page.

I noticed that from the login I receive a cookie called JSESSIONID (don't really know if the name is set by HttpClient() or the site itself).

Perhaps I need to send the session id with the next requests?

If so, how can I do it?
Who is Participating?
objectsConnect With a Mentor Commented:
are you passing the cookies back with the response?
although could be anything, sites do this sort of thing to stop people doing exactly what you are trying to do :)
CEHJConnect With a Mentor Commented:
It's always better to observe what a 'real browser' is doing on the site. Use a proxy such as


then you can simulate (in theory) easily
> Perhaps I need to send the session id with the next requests?

You pretty surely need to.
I'd suggest passing the recieved cookie with the next request.
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

b_locoAuthor Commented:

Sorry for the late reply...

I've made some progress but got stuck again now...

I've got 5 requests to do: 2 concern the login and the following 3 concern the desired operations.

On the first two, I get 2 cookies:

On the last requests I get:

Funny is that with charles (thanks CEHJ) I see that besides these two cookies there is always another one called loginState that is either false or true. I don't seem to get this last cookie...

Any clue on the INVALID_REQUEST or the missing cookie?
b_locoAuthor Commented:
As probably there was no obvious way of going around my problem I will split the points according to the number of responses
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.