File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Session Logging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session Logging" Watch "Session Logging" New topic
Author

Session Logging

Naina Srivastava
Greenhorn

Joined: Jun 20, 2002
Posts: 10
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

Joined: Mar 22, 2000
Posts: 12835
    
    5
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

Joined: Jun 20, 2002
Posts: 10
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

Joined: Jun 20, 2002
Posts: 10
Please let me know what will happen when the session is migrated to another JVM.
Thanks
Moorthi Ramasamy
Greenhorn

Joined: Jan 02, 2004
Posts: 15
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session Logging