Reputation: 873
I'm working on Struts 2 with Hibernate 3 . In my application I've many users and one would be admin. The privileges of each user will be stored on their HTTP Session. When the admin user makes some changes on the other user who is currently logged in, how can I make it to update onto his session. I know I can get that from database but I don't want to hit database for every action. Is there any better way to do it?
Upvotes: 1
Views: 189
Reputation: 160291
Your best bet is probably an HttpSessionListener and keep references somewhere, e.g., a static map of <Integer, HttpSession>
using the user ID as the Integer
key.
In your session listener add the session, in your log out and session invalidation (e.g., timeout) make sure you remove it, although it likely doesn't matter.
There are a number of synchronization issues this will bring up, but if you're familiar with such things, none of them are terribly difficult to resolve.
Upvotes: 1