• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

A doubt about sessionDestroyed method in HttpSessionListener

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I studied that sessionDestroyed method will be fired when a session is about to invalidate .

To understand this created a program in which I set a session's maximum inactive time as five seconds using setMaxInactiveInterval method of HttpSession

as


and I expect sessionDestroyed method will be invoked before that seconds(5 seconds) which I set using setMaxInactiveInterval method but it did not .

sessionDestroyed method invoked after a minute .

Why is it so ? .I'm using Tomcat 5.5.27 (servlet 2.4 version)

Thanks in advance

 
author & internet detective
Posts: 40791
828
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Parthiban,
As I recall setting the max inactive time allows the servlet container to invalidate the session after that. Rather than being a promise to invalidate it exactly that. What you are seeing is consistent with my memories of how this works.
 
Parthiban Malayandi
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:Parthiban,
As I recall setting the max inactive time allows the servlet container to invalidate the session after that. Rather than being a promise to invalidate it exactly that. What you are seeing is consistent with my memories of how this works.



Hi Jeanne ,

Thanks for your reply but what confuses me is the servlet specification:
It says that sessionDestroyed method will be invoked before the session invalidates which is what confuses me

Here's the extract from the specification

SRV.1.6.1 HttpSessionListener.sessionDestroyed
==============================================

In the previous versions of the specification, this method was defined as:
Notification that a session was invalidated.
As of Version 2.4, this method is changed to:

Notification that a session is about to be invalidated

so that it notifies before the session invalidation. If the code assumed the previous
behavior, it must be modified to match the new behavior.

Please clarify me.
 
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Parthiban Mahiby wrote:SRV.1.6.1 HttpSessionListener.sessionDestroyed
==============================================
In the previous versions of the specification, this method was defined as:
Notification that a session was invalidated.
As of Version 2.4, this method is changed to:

Notification that a session is about to be invalidated

so that it notifies before the session invalidation. If the code assumed the previous
behavior, it must be modified to match the new behavior.
Please clarify me.



According to the spec Yes, If the container running the code conforms to the Servlet 2.4 spec.
 
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Notification that a session is about to be invalidated


I think this can further be clarified in that session scoped attributes are still valid if called from within sessionDestroyed().
Hence at this point the session is still valid, but about to be invalidated.
 
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

To receive notification events, the implementation class must be configured in the deployment descriptor for the web application.


From J2EE 5 documentation. How did you find out that sessionDestroyed method was invoked after a minute?
 
Parthiban Malayandi
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eduardo Bueno wrote:

To receive notification events, the implementation class must be configured in the deployment descriptor for the web application.


From J2EE 5 documentation. How did you find out that sessionDestroyed method was invoked after a minute?



Hi Eduardo,

Thanks for your reply I had written a Listener class to find that.
 
Parthiban Malayandi
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Thanks for all your replies.which helpmed me to get it.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic