• 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 Time out

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to show an alert message when session time out, during application execution? Please let me know.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This application is web application or stand alone java application
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'd have to poll the server (probably via Ajax and timer event) to find out--the server can't push this information to the client.
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
If we hit the server using Ajax then would not it keep the session alive on server?
Please correct me if I understood this wrong.

Regards,
Amit
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In that case you cant use session time out method [setMaxInactivInterval].

1. Poll an AJAX request and manually calulate the timeout period

if(CurrentTime - HtpSession.getCreationTime - timeOut) = TIMEOUT - [alter_period]) {
sendalert response to rest timeout.
}else if(CurrentTime - HtpSession.getCreationTime - timeOut) = TIMEOUT){
invalidate
}

2. write another filter resetTimeOut

if(request = isNot[AJAX timeout request]
- reset timeout variable


This is the best i got.
 
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure if i have the answer but ...
when the session has timed out then the class that is implementing HttpSessionListener interface can do something.... given that you want to do something AFTER the session has timed out
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But one thing such a listener cannot do is to communicate with the client in any way. To issue an alert, for example.

The OP is thinking of the problem backwards. Upon a request, whether the session has expired of not can be checked (a filter is great for this). But if no request has been made, there's not much to be done.
 
The longest recorded flight time of a chicken is 13 seconds. But that was done without this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic