File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Warning on session time out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Warning on session time out" Watch "Warning on session time out" New topic

Warning on session time out

sreeni san
Ranch Hand

Joined: Aug 14, 2001
Posts: 39
How do I give a warning message when Session times out for a user. I am using Java Webserver 2.0.
Steve Granton
Ranch Hand

Joined: Jan 13, 2002
Posts: 200
In your control logic you can call:
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.
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

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.

- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

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

Joined: Apr 09, 2002
Posts: 65
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 ]

SCJP2 (1.4)
I agree. Here's the link:
subject: Warning on session time out
It's not a secret anymore!