?
Solved

Jakarta.commons.httpclient  session handling

Posted on 2004-08-25
7
Medium Priority
?
300 Views
Last Modified: 2008-01-09

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?
0
Comment
Question by:b_loco
  • 2
  • 2
  • 2
6 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 60 total points
ID: 11896890
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
 
LVL 92

Expert Comment

by:objects
ID: 11897968
> 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
 
LVL 2

Author Comment

by:b_loco
ID: 11929348
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 92

Accepted Solution

by:
objects earned 90 total points
ID: 11929361
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
 
LVL 2

Author Comment

by:b_loco
ID: 12254492
As probably there was no obvious way of going around my problem I will split the points according to the number of responses
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12256756
8-)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question