This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Warning on session time out

 
sreeni san
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
How do I give a warning message when Session times out for a user. I am using Java Webserver 2.0.
Thanks
Santosh
 
Steve Granton
Ranch Hand
Posts: 200
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In your control logic you can call:
request.getSession(false);
this will return null if no session is associated with the request and depending on the result of this you can redirect the user to a session timeout page.
Thanks,
Steve
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and remember, HTML is stateless, so there's no way to contact the client WHEN their session times out. You can only notify them the next time they make a request to the application with the method Steve Granton mentioned.
Also, check out the HttpSessionBindingListener -- it allows you to do things on the server side when the session expires.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And because you're using Java WebServer 2.0, you may run into a few problems.

If I remember correctly, sessionbinding stuff was a bit flakey when it was first introduced.
 
Toby Davis
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Servlet 2.3 API makes it easier. Here's an older thread talking about it some - but it has links to dead threads there.
JavaPro has information on session listeners, among other cool additions in 2.3 API.
Of course, you'd have to move to a compliant app server.
---
[ April 19, 2002: Message edited by: Toby Davis ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic