Jsp-When Browser Closed

Discussions

Web tier: servlets, JSP, Web frameworks: Jsp-When Browser Closed

  1. Jsp-When Browser Closed (1 messages)

    Dear all
    I need to know when th user browser is shutdown suddenly
    so i need to run some code such as remove user ID from Vector or any another thing

    so how can i do that , using what
    thanks alot for help
  2. Using Javascript for IE6[ Go to top ]

    Well, as HTTP is stateless, you need the browser to explicitly tell the server that it is closing. There is no 100% perfect way to do this, so you will need to mess around with some client-side scripting. You can try using the onunload attribute of the <body> tag to run some script (i.e. a post) when the window closes.

    I have used this for Internet Explorer 6, to process a form action when the window closes:

    <html>
       <head>
             <script type="text/javascript">
    function doUnload()
    {
               if(window.screenTop > 10000)
                  document.myform.submit();
    }
          </script>
          <title>My Document</title>
       </head>
       <body onunload="doUnload()">
            <form action="/myWebapp/logoff" method="post" name="myform">
    <!-- possible hidden form fields here -->
    </form>
       </body>

    I hope this helps somewhat