Jsp-When Browser Closed


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:

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

    I hope this helps somewhat