This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I would like to know as to how i can make the user to logout automatically when the borwser window is closed or when the"BACK" button in browser is clicked.Is there any way of ensuring that the user doesn't view other pages without once the window is closed or when the "BACK" button is pressed <b>AFTER </b> login?
This has been discussed in this forum before, but I don't think a clear solution was offered. One way you can do this is by using Applets instead of jsps & servlets. But I guess we don't want that. You can try searching the archives though.
Hi, See if this can help you? Same problem was faced by me some time ago. But i sorted this problem by using a database table. Create a temporary table and store some values like login , password , some random string and the system time. When ever user call some other page or servlet it will check the time entered in the table. If the time in table is older. Delete the row from the table and redirect user to login page. You can delete all old timings from the table whenever some JSP or servlet is invoked. Like some other person logs in the servlet or JSP will check all values of time, if they are old then it will delete them all.
You dont have specific solution to logout the user if the browser is closed or back button is pressed. Harshad
Joined: Aug 06, 2001
Logout.jsp(Close the session) ---------- <% session.invalidate(); %>
And Every jsp/servlet U have to check the session. If session is equal to null then go to the login page.
Joined: Feb 20, 2001
When the application starts, I had it open another window telling the user to log out by clicking a button. The user works on other part of the application and when everything is done, he click the logout window. I know this does not prevent him from closing the window by clickig "x" but I guess its better than nothing. Anyway, the session will timeout.