Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Killing session on closing a browser

 
Saravanan V
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
ray bond
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic