Hi, how would i know when user closes the browser.because i have to roll back some of the transactions when user closes the browser. from html i can use onunload method .but i want to know browser closing event at server side.At the same time how can i know particular session is inactive? our session timeout period is about 15 minutes so i can't wait for session timeout and rollback. Thanks in advance [ March 08, 2004: Message edited by: Rehana Shaik ]
"Cluck Cluck"- Welcome to the JavaRanch! Please adjust your displayed name to meet the JavaRanch Naming Policy. You can change it here. Thanks! and welcome to the JavaRanch! Good Answer to the question though. Mark
Leaving a transaction open and waiting for user intervention is usually a bad idea. You might want to re-think what you're doing. If you can (if it's not a lot of data), you might want to gather up everything you need to perform the transaction and store it in the session. Then, at the end, you use that information to perform the entire transaction during one request. If the user closes their browser or their session times out, the data for the transaction is lost. You could actually save the data in the database (marking it as temporary or provisional somehow) and listen for session timeout events (via an HttpSessionListener) to clean it up. However you do it, I would NOT leave open a JDBC connection to the database while waiting for the user to do something. That can be quite a resource hog, especially if your session-timeout value is large. Just my $0.02.
James Carman, President<br />Carman Consulting, Inc.
At the same time how can i know particular session is inactive?
Add a class implementing HttpSessionListener interface in your application. this interface has 2 methods - 1. sessionCreated 2. sessionDestroyed when your session gets inactive, sessionDestroyed() method would be called to indicate the same. Dont forget to register this class as listener in your web.xml. I hope, this helps. :-)
That's a very big dog. I think I want to go home now and hug this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database