How to close a session

Discussions

EJB programming & troubleshooting: How to close a session

  1. How to close a session (2 messages)

    Hi,
    I have made a shopping cart where user has to login. I have used stateful session bean to manage the session. Now the problem is that even after shutting down computer, the user is not getting logged off.
    Please tell me how to kill a session when user logs out or system is shut down.
    I am using JBoss 3.2.1
    Abhishek.

    Threaded Messages (2)

  2. How to close a session[ Go to top ]

    What kind of "session" are you talking about? The application session, or the statefull session?
    In the latter case, the session must be removed with session.remove(). You can achieve this implementing a session listener that gets notified when the user's session expires, and performs the removal.
    In the case of a non-web client, where the application can be killed in many ways (unplugging the users PC, for instance), you may not have any chance to detect that situation; the container should detect this (the client that created a statefull session is not there anymore). I guess this should be somewhere in the EJB spec, but I don't quite remember...

    Cheers and happy coding,
    Martin
  3. How to close a session[ Go to top ]

    Adding to Martin's response, if you have a non-web client you could just follow the idea of web sessions - set an expiration on session.

    Have a session manager that monitors the open sessions and test them for inactivity.