Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session expired or not ?

 
hasan khan
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • 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 ?
 
Mikalai Zaikin
Ranch Hand
Posts: 3371
12
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
will this solve my problem HttpServletRequest.isRequestedSessionIdValid() ?
 
Mikalai Zaikin
Ranch Hand
Posts: 3371
12
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic