Solved

Jakarta.commons.httpclient  session handling

Posted on 2004-08-25
7
277 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
7 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 20 total points
Comment Utility
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
Comment Utility
> 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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 92

Accepted Solution

by:
objects earned 30 total points
Comment Utility
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
Comment Utility
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
Comment Utility
8-)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now