aspose file tools*
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
Author

Warning on session time out

sreeni san
Ranch Hand

Joined: Aug 14, 2001
Posts: 39
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

Joined: Jan 13, 2002
Posts: 200
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

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: http://aspose.com/file-tools
 
subject: Warning on session time out