File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes logOut script not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "logOut script not working" Watch "logOut script not working" New topic

logOut script not working

Stephen Wei
Ranch Hand

Joined: Oct 09, 2001
Posts: 73
Hi, I am assuming user use IE browser which supports Javascript. I want my LogoutServlet to run when the user pushes the logout button or close the browser. Here is my code, but my servlet will not get executed, my browser closes ok(I want the browser to close when the user logout), why is this? When I remove the "window.close();" line, my servlet will execute, is it because my window closes too quickly before it submits the form?
< script language = "javascript">
function logOut()
window.event.returnValue = false;
window.event.returnValue = true;
< p
align="center"> < input type="submit" value="logout" action="http/myhost/Servlet/LogoutServlet"
"onclick"="logOut()"> //I put an extra quotation here because otherwise I could not submit this message to Javaranch, strange.
< /p>

Also, can someone explain the "onclose()" function to me? How do I submit a request to the servlet using only Javascript? something like:
} /

Sun Certified Programmer for Java Platform
Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
In your logout servlet set some flag come back to the page read the flag and invoke window.close() after reading the flag in body onload instead of calling window.close() in logout function.

SCJP, SCJD, SCWCD1.4, IBM486, IBM484, IBM 483, IBM 287, IBM141, IBM Certified Enterprise Developer - WebSphere Studio, V5.0
Author of IBM 287 Simulator Exam
I agree. Here's the link:
subject: logOut script not working
It's not a secret anymore!