users@glassfish.java.net

Re: clusterjsp sample losing session data

From: <glassfish_at_javadesktop.org>
Date: Mon, 11 Aug 2008 10:15:07 PDT

Hi Cameron:

Sorry you are having trouble - but please spare your hair.

From your description it appears that you are running into an issue that is somewhat inherent in web containers - it has to do with thread semantics.
The container is written in such a way that it is expected that only one foreground thread at a time (per session id) will be manipulating the http session for that id.
Given this, there are unsafe practices that you should avoid:

a) hitting the container with repeated requests containing the same JSESSIONID (i.e. session id).
instead you want to insure that the response has come back to the client before sending any subsequent requests. That is why (for example) you often see web clients which do things like use javascript to immediately disable a button when it is pressed - to avoid hitting it over and over again too quickly.

b) when using Frames, you must ensure that only one of the frames is doing the manipulation of http session. The reason for this is, again, that each Frame in a request becomes a separate thread.

If you follow these practices your app should behave correctly.

hope this helps
[Message sent by forum member 'lwhite' (lwhite)]

http://forums.java.net/jive/thread.jspa?messageID=292638