[thelist] JSP Sessions duplicate

Edwin Martin edwin at bitstorm.org
Thu Jun 9 04:01:36 CDT 2005


VOLKAN ÖZÇELİK wrote:

> User A logs in -> a User object is created for him and stored in A's session.
> User B logs in -> a User object is created for him and stored in B's session.
> 
> this is the normal case as you may guess.
> 
> And here is the very rarely-occuring (but occuring anyways) situation:
> 
> User B logs in, but when he requests the user Object from his session,
> he sees that it is A's User object. (in other words he sees A's name
> on the browser window)

This sounds like the code is not thread-save.

A Java webapplication (JSP included) is typically multi-threaded.

There are two solutions:

1) Disable multi-threaded processing (you can do that with a JSP-tag)

2) Write threaded-save code (for better performance).

Edwin Martin



More information about the thelist mailing list