Sounds to me like a threading issue. Keep in mind that the set is not a thread safe construct, and just adding the entry to the context does not mean that more than one thread accessing will be able to see the values properly.
Adrian Janssen wrote:
Hi,
I am a bit perplexed as to how storing attributes in the ServletContext is supposed to work, I am storing a HashSet of active users in in the ServletContext.
When I want to add a user to this set I get the HashSet using the "getAttribute ( String )" method, then I add a userId to the set.
What I have found though, is unless I do a "setAttribute ( String )" again the user does not seem to get added to the set.
Is this how it is supposed to behave? This seems to imply that the "getAttribute" method either REMOVES the set from the ServletContext or CLONES it (very unlikely)?
If it is not removing it then merely adding an item to the set without using "setAttribute" should work, as surely I am refencing an object that is still in the ServletContext.
Perhaps this is a wierd side-effect of Tomcat version 4.0? Maybe Tomcat does something like serialize the ServletContext application collection, but it only re-serializes it if some "dirty" flag gets set, and this "dirty" flag only gets set if a set-attribute is done?
So to summarise:
Is the behavious I am getting correct? If not, what are your thoughts?
Cheers Adrian --
It is the strict policy of Truworths that its e-mail facility and all e-mail communications emanating therefrom, should be utilised for business purposes only and should conform to high professional and business standards. Truworths has stipulated certain regulations in terms whereof strict guidelines relating to the use and content of e-mail communications are laid down. The use of the Truworths e-mail facility is not permitted for the distribution of chain letters or offensive mail of any nature whatsoever. Truworths hereby distances itself from and accepts no liability in respect of the unauthorised use of its e-mail facility or the sending of e-mail communications for other than strictly business purposes. Truworths furthermore disclaims liability for any unauthorised instruction for which permission was not granted. Truworths Limited accepts no liability for any consequences arising from or as a result of reliance on this message unless it is in respect of bona fide Truworths business for which proper authorisation has been granted.
Any recipient of an unacceptable communication, a chain letter or offensive material of any nature is requested to notify the Truworths e-mail administrator ([EMAIL PROTECTED]) immediately in order that appropriate action can be taken against the individual concerned.
___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
