• 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

sessions

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Just a quick question on sessions. I am working on a site that adds a few different objects to the session. For example, User, Album and a few other values. What I want is for the session to expire only when the browser is closed and not if the user does not use the browser for say 15 min.
I have tried session.setMaxInactiveInterval(-1) but that does not seem to do it.
Anyone know how to do it?
Regards david
 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried using session-timeout tag in your web.xml.
If you set it with 0 it means that the session will never expire.
 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
You can set session-timeout tag (web.xml) to a value to 0 or less
Thanks
Sainudheen
 
david allen
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So if I edit the web.xml file so that the session tag is set to zero does this mean a session will only expire when the server is stopped?
What I am after is having the session expire when the browser is closed? Is this possible?
Regards
David
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sadly the browser does not tell the server when it closes. I don't think you can tell the difference between a)user closed the browser b)user went out for dinner & dancing or c)user is busily surfing other sites.
If you really, really gotta know (really!) you can put an applet in the browser and have it send "I'm still here!" messages to the server or have the server send "Are you still there?" messages to the applet. We're buying a vendor product that does this so it can synchronize telephony events and workflow availability with the browser. We're buying it because it ain't easy to build!
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think that "never expire" is what you want - if the servlet engine serializes sessions to disk, your hard drive will just accumulate sessions.
A "keep alive" pulse with JavaScript or applet sounds right for you - then you can let the servlet engine dispose of sessions normally.
Bill
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic