• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Session Time out

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
 
Marshal
Posts: 67279
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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.
 
pie. tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!