Detecting closing,pressing of back button ... of browser window

Hi

I have a servlet which processes the request initiated at a client.While the servlet is waiting for the response,if the user presses the back button,forward button,refresh button or simply closes the browser window,How does the servlet come to know of this.In this case what is the action to be taken by servlet.

[337 byte] By [samraghav] at [2007-9-26 2:45:55]
# 1
Hi I have solved this problemI have used the reponse object's flushbuffer method to throw an exception and i have caught the exception .This works. Please Note:: The flushBuffer() method is available only in servlet2.2 API.
samraghav at 2007-6-29 10:28:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
can u give me small eg for this.thanks in advanceregardssampath ramanujan
rsampath1978 at 2007-6-29 10:28:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Here is the code

import java.io.*;

import javax.servlet.*;

import javax.servlet.http.*;

public class process extends HttpServlet {

public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException

{

res.setContentType("text/html");

PrintWriter out = res.getWriter();

try{

Thread.sleep(5000);

for( int i=0; i<10000; i++ ){

out.println( "Did it\n" );

Thread.sleep( 2 );

res.flushBuffer();

}

} catch( Exception e ){

System.out.println( "> Exception " + e.toString() );

}

}

}

samraghav at 2007-6-29 10:28:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...