aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes session listener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "session listener" Watch "session listener" New topic
Author

session listener

Naresh Chaurasia
Ranch Hand

Joined: May 18, 2005
Posts: 356
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


SCJP 1.4, SCWCD1.4, OCA(1Z0-007)
ramya ray
Ranch Hand

Joined: Aug 11, 2006
Posts: 101
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

Joined: May 18, 2005
Posts: 356
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

Joined: May 18, 2005
Posts: 356
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

Joined: May 18, 2005
Posts: 356
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

Joined: Apr 30, 2001
Posts: 199
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: session listener