Sateful session bean HTTPSession


EJB programming & troubleshooting: Sateful session bean HTTPSession

  1. Sateful session bean HTTPSession (6 messages)

    I am storing session information in a stateful session bean. And storing that session bean in HTTPSession.
    Is there any way to get a notification , when the HTTPSession is time out or invalidated?
    If not, how do the stateful session bean cleans up its data(it is heavy in this case).


    Threaded Messages (6)

  2. Sateful session bean HTTPSession[ Go to top ]

    To get a notification you would have to have the ejbPassivate() and/or ejbRemove() method do "something" such as publish a message - then you would have to have "something" receive the message and notify (nullify) the HttpSession about the timed-out session bean.
    As for the session bean cleaning up its data, again, just put functionality in the ejbPassivate() and/or ejbRemove() methods of the bean to "clean up" whatever you wish.
    As a side note, what is the design of the stateful session bean? What "state" are you trying to maintain across multiple HttpSession calls? Is it user account info, references to a list of some sort? ...?
  3. Sateful session bean HTTPSession[ Go to top ]


    I am storing user input , in between different screens , before reaching the submit operation, which makes in persistant.

    Is servlet API provide support for soemthing like on_SessionTimeOut() event or call back?

  4. Sateful session bean HTTPSession[ Go to top ]

    I don't believe there is an on_SessionTimeOut() event or anything. The Session bean will clean up itself when it times out (container will, actually) if the HttpSession times out. As for notifying the bean that the HttpSession has timed out, as soon as the reference from the HttpSession to the Session bean is nullified (by HttpSession timeout), the Session will be lost also - at this point the container will call the ejbPassivate() on the Session bean, which is where you could provide your cleanup functionality.
  5. Sateful session bean HTTPSession[ Go to top ]

    Hi Shaun
       I cant seem to understand how the statefull session bean ( on app server) will know when an httpsession(on webserver) will expire?
  6. Sateful session bean HTTPSession[ Go to top ]

    thanks Shuan.
  7. Sateful session bean HTTPSession[ Go to top ]

    Hello... simple...
    make your session bean implements the HttpSessionBindingListener interface from the servlet API. So before the jsp session which your session bean is in will expire, the method valueUnbound(HttpSessionBindingEvent event) will be called. In there you could do any code needed.