Yes, you are right. It s not JSF-specific.
After all, what is the functional requirement?
The application should the other user logout immediately with(out) notification and proceed with login?
I use EJBs and an EJB-Container.
Maintain somewhere in the application scope a Map<User, HttpSession> so that you can control over it.
Okay, at first I store a Map in my application scope, when the User logs in.
I need a ServletContext and "setAttribute"
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html:
Binds an object to a given attribute name in this servlet context. If the name specified is already used for an attribute, this method will replace the attribute with the new to the new attribute.
I call something like
I have tried to get the application with
But it does not work! (I have not implement it into a Servlet, I implement it in a ManagedBean).
However, assume it is working, then I can call the HttpSessionListener: when the same User registers twice, the Session of the User before is overwritten and hence destroyed, when I do this method in my login-logic:
application.setAttribute(User, Session)
So when the Value of the Users Session changes, then the HttpSessionListener calls the sessionDestroyed-Method..
Is this the right way. Have I better possibilities to do that?