?
Solved

Jakarta.commons.httpclient  session handling

Posted on 2004-08-25
7
Medium Priority
?
291 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
7 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

801 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