wood burning stoves 2.0*
The moose likes Servlets and the fly likes I *want* multiple sessions from multiple clients logged in from one machine Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "I *want* multiple sessions from multiple clients logged in from one machine" Watch "I *want* multiple sessions from multiple clients logged in from one machine" New topic
Author

I *want* multiple sessions from multiple clients logged in from one machine

Joe Gilvary
Ranch Hand

Joined: May 11, 2001
Posts: 152
I've searched in this forum to see if anyone has worked through something like this before. I see a lot of people working on ways to prevent multiple simuultaneous accesses by a single client, but that is just what I want to create.

I want to use a multi threaded client to simulate load on a web app. The application stores some persistent data in the session. Each thread will request different information to model real world behavior more closely.

The problem is that the app server sees each thread as the same client (via cookies) coming from the same process on the same machine and subsequently lets them step all over one another's session-stored data.

I need to fix this on the client side. The purpose is testing the web app we will deploy, not changing the app to something we can more easily test. The real world clients are locked down and will use cookies, so URL rewriting is testing something besides what we will deploy.

I know I can use separate JVMs instead of threads, but then I need more hardware to simulate the same load. I prefer threading if I can find such a solution.

TIA,

Joe
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If you're writing the client, you can set whatever you want for the headers.
Just don't pass the JSESSIONID header and the server will treat each request as a new session.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Joe Gilvary
Ranch Hand

Joined: May 11, 2001
Posts: 152
Originally posted by Ben Souther:
Just don't pass the JSESSIONID header and the server will treat each request as a new session.
Thanks, Ben.

I didn't give you enough information. I don't want every request to be a new session. I want every thread to have an individual session for its use over several requests. Each thread should pull data from the backend to the client, possibly modify it, and send it back through the web app to the persistent store. To look more like the real world, each thread should access different records. Currently they step on one another's requests because they're all in a single session.

Thanks,

Joe
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Have each thread hit the app once to get a JSESSIONID.
Then set the header with that value for all subsequent hits by that thread.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
It sounds to me like you need the HttpClient package from the Apache Jakarta commons project.
I have used this to simulate large numbers of "clients" with separate sessions from a single machine.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I *want* multiple sessions from multiple clients logged in from one machine
 
Similar Threads
Session or No Session?
multithreaded web application session issue
Monitoring other objects
sessionId
Cookies In session