File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes how to disable session using javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to disable session using javascript" Watch "how to disable session using javascript" New topic

how to disable session using javascript

ashishagarwal agarwal

Joined: May 04, 2006
Posts: 4
I need to expire the session whenever anyone closes the window without signout.

I know I can not use java (session) object in javascript functions.

Can I use AJAX ? if yes can you send me some sample application?

Ashish Agarwal
Satish SN
Ranch Hand

Joined: Apr 19, 2005
Posts: 70
Hi Ashish,

i think u can handle it through javascript

u can write a function on the window close event and call a servlet/jsp through which u can invalidate the user session.

try this out i think it should work

Satish SN<br />SCJP 1.4 & SCWCD 1.4
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17271

I am going to move this to the Servlets forum, and hopefully that is the best forum for you question.


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63053

There is no way to reliably detect the closing of the browser. Please see the many posts on this topic already in the HTML forum.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

This topic is also disussed frequently in this and the JSP forums.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Don't get me started about those stupid light bulbs.
subject: how to disable session using javascript
It's not a secret anymore!