• 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

Listener to detect when session ends

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to do url tracking using a filter. I want to build up a string of delimited servlet names and insert then into a database. the tables would then be deleted every so often.
What type or is there an example i can use of a listener that will trigger the insert when the user closes the browser, loggs out, or the session expires?

thanks in advance
john
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Schretz wrote:...What type or is there an example i can use of a listener that will trigger the insert when the user closes the browser, loggs out, or the session expires?
thanks in advance
john



trigger when the user closes the browser? None. You may find some javascripts that can be used to make a new request to the server informing it that the browser is being closed.

trigger when the user logs out? Depends how you log out. If you invalidate a session when they log out then see below.

trigger when the session expires? Use an HttpSessionListener (API Link)
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Steve Luke wrote:
trigger when the user closes the browser? None. You may find some javascripts that can be used to make a new request to the server informing it that the browser is being closed.

Even then, this isn't going to be crossbrowser compatible as at least Opera doesn't support it. Even then though, I won't use it. What if the user disabled Javascript? It can never be as reliable as you could do at the server side. Implementing the HttpSessionListener is the right approach, yes.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bauke Scholtz wrote:
Even then, this isn't going to be crossbrowser compatible as at least Opera doesn't support it. Even then though, I won't use it. What if the user disabled Javascript? It can never be as reliable as you could do at the server side. Implementing the HttpSessionListener is the right approach, yes.



But when its possible to get the information close enough, why not get it. Otherwise, Listener is there in place.

Moreover, JavaScript disabled is not really the case to consider, IMHO, if not there as a requirement exclusively.
 
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
Trying to detect when the browser closes is folly. As it cannot be done reliably, any suppositions based upon that is suspect.
 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for the late response I have been really busy
Just wanted to say thank you and i will look into HttpSessionListener
I will post any results i come up with
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic