Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Logging

 
Naina Srivastava
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an application deployed on WebSphere Application Server 4.0( supports Servlet 2.2). I want to log following events:
1. Session is created.
2. Session is destroyed
Please let me know how can I do this. Please reply soon.
Thanking in advance.
Neha
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I recall, the HttpSessionBindingListener interface was supported in the 2.2 API (more listener interfaces were added with 2.3). You could add an object implementing this interface to every new session. It will get notified on the initial adding and when the session is destroyed.
Bill
 
Naina Srivastava
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the reply.
Could you please let me know what will be its behavior in a distributed environment?
Regards
Neha
 
Naina Srivastava
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please let me know what will happen when the session is migrated to another JVM.
Thanks
 
Moorthi Ramasamy
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Neha Srivastava:
Please let me know what will happen when the session is migrated to another JVM.
Thanks

An object that implements the HttpSessionListener interface is notified when a session is created or destroyed in its web app context
interfaces (or classes): javax.servlet.http.HttpSessionListener
methods:
void sessionCreated(HttpSessionEvent e)
void sessionDestroyed(HttpSessionEvent e)
- called when session is destroyed (invalidated)

<B>behavior in a distributable: sessions may migrate from one jvm or machine to another; hence the session destroy event may occur on a different jvm/machine than the session create event. </B>
Thanks,
Moorthi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic