Storing an application wide variable in a clustered environment

I'm working on a security issue that prevents a user from logging on if they already have an existing session on the server.  I found a good solution for this where I store the user's id in a HashSet inside the ServletContext when they log on, so if they log in again, I just check do a "contains(userId)" and find out if they are logged on.  The problem with this is, I don't think the ServletContext is shared between clustered machines.  I thought about using the database, but if the power goes out on the application server, the record will remain in the table instead of being removed at the end of the session.  

I'd appreciate any ideas.
sb1977Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rrzCommented:
>I thought about using the database, but if the power goes out on the application server, the record will remain in the table instead of being removed at the end of the session.    
You could create a servlet that  loads on start-up  that could clear your db record and start fresh.    
I guess you are doing something like what dicussed at  
http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21794750.html     
0
rrzCommented:
>I don't think the ServletContext is shared between clustered machines.    
I am not sure about that.  I don't have experience with clustering but it doesn't sound right. I guess you saw these pages.
http://www.onjava.com/pub/a/onjava/2004/03/31/clustering.html
http://www.onjava.com/pub/a/onjava/2004/04/14/clustering.html?page=1     
You should post your configuration. So, if an expert see this, he will be able to comment.     rrz
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bloodredsunCommented:
>>I don't think the ServletContext is shared between clustered machines.  

That's correct from my experience with WebSphere clusters
0
rrzCommented:
Thanks bloodredsun. ( nice picture)
What about using a Servlet or Filter  init  methods ? Is that a good idea ?
0
bloodredsunCommented:
I think rrz is right in suggesting a servlet. Use a load on startup servlet that cleans out the table in the database in case of a crash and your problem is solved.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Storage Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.