aspose file tools*
The moose likes Servlets and the fly likes Session Interference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session Interference" Watch "Session Interference" New topic
Author

Session Interference

Raghav Sam
Ranch Hand

Joined: Apr 12, 2001
Posts: 412
Hi,
I'm getting weird things on my user sessions, so i was wondering... ...Is the HttpSession thread-safe? I'm having users objects 'setted' on other users sessions, so, may it be that i need to enclose the code in a 'synchronized' block? I'll appreciate any help.


Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind.<br />- Dr. Seuss
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3879
Yes, HttpSession should be threadsafe. You don't need to synchronize access to it.
Are you saying you're getting objects from one user's session placed on another user's session?
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Raghav Sam
Ranch Hand

Joined: Apr 12, 2001
Posts: 412
Originally posted by Kyle Brown:
Yes, HttpSession should be threadsafe. You don't need to synchronize access to it.
Are you saying you're getting objects from one user's session placed on another user's session?
Kyle

Yes. There seems to be a mixup. I am actually storing value objects (obtained from the user input) in session and using the info in subsequent pages.
On one occasion, the entire contents of the bean seems to have been overwritten with some other data.
If I should not synchronize it, how should I make sure that data integrity is maintained between different sessions.
Raghav
shankar vembu
Ranch Hand

Joined: May 10, 2001
Posts: 309
Originally posted by Raghav Sam:

Yes. There seems to be a mixup
On one occasion, the entire contents of the bean seems to have been overwritten with some other data.

This will not happen. I guess you should check your application logic...
Originally posted by Raghav Sam:

If I should not synchronize it, how should I make sure that data integrity is maintained between different sessions.

You dont have to worry about maintaining data integrity b/w different sessions...
Regards
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12681
    
    5
On one occasion, the entire contents of the bean seems to have been overwritten with some other data.
If I should not synchronize it, how should I make sure that data integrity is maintained between different sessions.

I am betting that you are storing a reference to the bean as an instance variable in your servlet class. Remember - any number of requests can be undergoing processing "at the same time" so you can't use instance variables to store anything that changes with the user.
Bill


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session Interference
 
Similar Threads
Problem:When two users submit the form concurrently.One of the form is not getting submitted.
Getting active session from the session id
To write a chattting programme
HttpSession concept
Get session attribute values from all activated session's