modsiw
asked on
Detect that tomcat as restored a session after stop / start
How can I detect that tomcat has restored a HttpSession from persistence?
I'm looking for similar behavior to HttpSessionListener that is triggered when a session is made.
I'm looking for similar behavior to HttpSessionListener that is triggered when a session is made.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Another note:
I don't have a tomcat cluster. It seems HttpSessionActivationListe ner was designed to service clusters. Could this be an issue?
I don't have a tomcat cluster. It seems HttpSessionActivationListe
From
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpSession.html
"When container migrates a session between VMs in a distributed container setting, all session attributes implementing the HttpSessionActivationListe ner interface are notified."
I can't test either. So I don't where we can go with this.
I googled,
http://www.xyzws.com/Servletfaq/when-do-i-use-httpsessionactivationlistener/4
http://www.coderanch.com/t/170002/java-Web-Component-SCWCD/certification/HttpSessionActivationListener-configured-DD
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpSession.html
"When container migrates a session between VMs in a distributed container setting, all session attributes implementing the HttpSessionActivationListe
I can't test either. So I don't where we can go with this.
I googled,
http://www.xyzws.com/Servletfaq/when-do-i-use-httpsessionactivationlistener/4
http://www.coderanch.com/t/170002/java-Web-Component-SCWCD/certification/HttpSessionActivationListener-configured-DD
ASKER
My tests and those links indicate that HttpSessionActivationListe ner won't solve my problem. :(
>Detect that tomcat as restored a session after stop / start
I don't think that ever happens.
Please tell us more about your problem.
I don't think that ever happens.
Please tell us more about your problem.
ASKER
When I log on to my site, attributes are added to my session and my session is added to a static collection.
If I stop / start the server then refresh my browser those attributes are still there which is evident because the site still knows that I am user xyz and have preferences abc which were set in the attributes of my session.
The collection is reinitialized with the server. If I view a list of logged on sessions which is taken from this collection, it is empty. I need some way to populate it with the HttpSessions that persisted.
If I stop / start the server then refresh my browser those attributes are still there which is evident because the site still knows that I am user xyz and have preferences abc which were set in the attributes of my session.
The collection is reinitialized with the server. If I view a list of logged on sessions which is taken from this collection, it is empty. I need some way to populate it with the HttpSessions that persisted.
ASKER
The collection I mentioned in my preview comment is Monitor.mapSession from my example code above.
ASKER
I figured out why my HttpSessionActivationListe ner method's weren't being called:
I was using it like HttpSessionListener. Eg, expecting tomcat to call it bc it is a registered listener.
It should be used like HttpSessionBindingListener and attached as an attribute to the sessions.
I was using it like HttpSessionListener. Eg, expecting tomcat to call it bc it is a registered listener.
It should be used like HttpSessionBindingListener
Great, I am glad that you kept working and found the solution.
>It should be used like HttpSessionBindingListener and attached as an attribute to the sessions.
I guess the API( that I cited above) wasn't very clear.
>It should be used like HttpSessionBindingListener
I guess the API( that I cited above) wasn't very clear.
ASKER
The docs could be read either way, but there was a red herring.
It has the same event type as HttpSessionListener, which is not the same event type as HttpSessionBindingListener . So I subconsciously decided it behaved like HttpSessionListener without really questioning it.
It has the same event type as HttpSessionListener, which is not the same event type as HttpSessionBindingListener
ASKER
<listener>
<listener-class>com.floors
</listener>
sessionCreated is called when I log on, but if I stop / start the server, sessionWillPassivate / sessionDidActivate are not called
Any idea what I'm doing wrong?
Open in new window