• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session listener

 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
page 211 of HFSJ says:

An HttpSessionListener can be used to perform an action when an HttpSession has timed out.

My doubt is that listener method, sessionDestroyed() is called just before the session is destroyed, because once the session is destroyed, there is no way to access the session object. So the above statement should be

An HttpSessionListener can be used to perform an action before HttpSession is timed out..

Please clearify my doubt..thnx in advance
 
ramya ray
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually the first statement is correct -

HttpSessionListener are configured in such a way that everytime a session is created or destroyed they are notified with proper events.

So in the statement it tries to say once session destro method is called - httpSessionListener will be called.

Thanks,
 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if the sessionDestroyed method is called after the session object is destroyed, then how can i take some action of the attributes that are stored in session( since the session object is destroyed i want have access to the attributes stored in session object)
 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a method sessionWillPassivate in HttpSessionActivationListener, that would help me take appropriate action before the session is timed out.....i guess that answers my question...


thanks
 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sessionWillPassivate in HttpSessionActivationListener is called when the session object migrates from on JVM to another JVM..I guess my question is still un-answered.
 
Bryan Basham
author
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by N Chaurasia:
if the sessionDestroyed method is called after the session object is destroyed, then how can i take some action of the attributes that are stored in session( since the session object is destroyed i want have access to the attributes stored in session object)


Hello,

In English there is a subtle difference between "when X" and "after X". "When X" means something else happens at the same time as X. "After X" means that something else happens after X has completed. The javadocs for this method says "Notification that a session is about to be invalidated." The phrase "is about to be" is essentially equivalent to "immediately before." OK, enough of the language lesson...

Reading between the lines, I would interpret your question as: "When the sessionDestroyed() method is called, do the session attributes still exist?" The answer to that question is: yes.

HTH,
Bryan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic