jQuery in Action, 3rd edition
The moose likes JSP and the fly likes HELP!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » JSP
Bookmark "HELP!!!" Watch "HELP!!!" New topic


Anthony Smith
Ranch Hand

Joined: Sep 10, 2001
Posts: 285
I am in BIG Trouble. I got an app using jsp's and Servlets... When A user logs on, and then closes the browser, I want them to be logged off. I cant wait for anytime out function, unless there is one that constantly checks for something. I need this because a user cannot do multiple logins and your second login cannot log you off of your first login. I got that part working. But if I log in close the browser and then try to login somewhere else, I should be able to, btu I cannot cause while I chek for a session, my db has not way of knowign a user has logged off.
Can someone please help
Joe Gilvary
Ranch Hand

Joined: May 11, 2001
Posts: 152
You need to force users to log out, or run a very short
timeout on the session. The short time out will be more
trouble than it solves.
When a user tries to log into a second session, can
you display a prompt that lets them log out of the
previous session if they did not log out?
Anthony Smith
Ranch Hand

Joined: Sep 10, 2001
Posts: 285
I understand what you are saying, but if they close their browser before logging out, they cant go back to log out. I need something, where if they try and close that browser it logs them out automaticaly, or asks them to log out.
If they try and login while already login I have that message, but they cant go back to logoff.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13001
The server has no way of knowing for sure when a browser is closed or a connection lost without something - Javascript or applet - running on the browser. You could have a "heartbeat" applet making a periodic call to the servlet and a timer to detect when it fails to check in.
NEVER title a message "HELP!!!" it does not tell a thing about what you need help with and wastes everybody's time. "Help with browser closing" would have been good.
Zac Roberts
Ranch Hand

Joined: Jan 29, 2002
Posts: 82
Are you running your application on Tomcat? If so there is a sort of built in login session tracking device. It password protects certain files that you specify and whenever a user tries to access them from a "fresh" browser or a new session they are required to login at a designated login screen. It seems to work on a small database app that I am running. I learned about it in Wrox's "Beginning JSP Web Development". Hope that helps.

Zac Roberts<br />SCJP2
sameera kocharekar

Joined: Apr 23, 2001
Posts: 23
Why dont u use a cookies.I mean set cookie with maxage as 0 so that when the user closes the browser the cookies expires ie gets deleted.
So when he agains logs in with another browser he would be asble to de so..

Have you checked out Aspose?
subject: HELP!!!
It's not a secret anymore!