aspose file tools*
The moose likes Servlets and the fly likes Killing session on closing a browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Killing session on closing a browser" Watch "Killing session on closing a browser" New topic
Author

Killing session on closing a browser

Saravanan V
Greenhorn

Joined: Sep 20, 2001
Posts: 15
Hi
I need a help on how to kill a session on closing a browser.I am handling sessions using servlets in weblogic application server.
Wishes
Saravanan.
arul senthil
Greenhorn

Joined: Jul 03, 2001
Posts: 29
Hi
The "Session" is always per browser-window basis & if u close the browser window, then it's all over. No need to kill the session explicitly.
Can u explain what do u want to do with session?
Saravanan V
Greenhorn

Joined: Sep 20, 2001
Posts: 15
Hi Senthil
Thanx for ur reply...Here is the scenario in my case..
I implement sessionlistener interface for doing operations for setting and resetting the flag when session is created and destroyed.I need this sessionDestroyed to be called when the browser is closed which means i need to trap that event.Hope the problem is clear now..
Wishes
Saravanan.
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Well the problem is that there is no way to know on the server-side that the browser has been closed. The only way to work around that is to set an appropriate timeout after which you close the session.
Also you might want to read the following thread which discusses the same issues.
http://www.javaranch.com/ubb/Forum50/HTML/000219.html
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
[This message has been edited by Valentin Crettaz (edited November 22, 2001).]


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
ray bond
Ranch Hand

Joined: Oct 11, 2000
Posts: 111
you can know at server side when the browser is closed, for this you have to integrate applet in those web pages , inside applet you can open printstream to servlet and in that applet's destroy method you can pass some notification to printstream to servlet. this way everytime servlet is notified if browser is closed and session ended.
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Originally posted by ray bond:
you can know at server side when the browser is closed, for this you have to integrate applet in those web pages , inside applet you can open printstream to servlet and in that applet's destroy method you can pass some notification to printstream to servlet. this way everytime servlet is notified if browser is closed and session ended.

Since the destroy() method is called every time you change pages, how would you tell the difference between closing the browser and going to another page? I don't think this would work...
Kyle

------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
 
wood burning stoves
 
subject: Killing session on closing a browser