• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

session expired or not ?

 
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a class MyHttpSessionListener which implements HttpSessionListener,
in sessionCreated() method

i am storing the session reference in to Hashtable and setting Hashtable as a attribute to the context. i am not removing the expired session from the Hashtable in sessionDestroyed() method.

i have a JSP which show all the session in the context (including active and expired) with some details such as (creation time, last access time, session id etc)
i also want to display that the session object expired or not. how do i do that ?

in short i want to know whether a given session object is expired or not ?
 
Bartender
Posts: 3904
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This may help:

(CURRENT_TIME - getLastAccessedTime()) > getMaxInactiveInterval()

Just make sure max inactive interval > 0

regards,
MZ
 
hasan khan
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
will this solve my problem HttpServletRequest.isRequestedSessionIdValid() ?
 
Mikalai Zaikin
Bartender
Posts: 3904
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This validates the current session only (from current request).
And you wrote that you store your sessions in Hashtable.

In case you have only 1 session (current) to validate, the request.isSessionIDValid() method works perfect, but what request object to use to validate other (previous) sessions from Hashtable ?

regards,
MZ
reply
    Bookmark Topic Watch Topic
  • New Topic