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?
LVL 2
b_locoAsked:
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 :)
0
 
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

http://www.xk72.com/charles/download.html

then you can simulate (in theory) easily
0
 
objectsCommented:
> 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.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
b_locoAuthor Commented:
Hi

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:
JSESSIONID=somestring
lastRequest=/somepage###someid

On the last requests I get:
JSESSIONID=sameStringAsAbove
lastRequest=INVALID_REQUEST###sameIdAsAbove

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?
0
 
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
0
 
CEHJCommented:
8-)
0
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.