I have this page:
<%@page language="java"%>
<html>
<head></head>
<body>
<% while(true) System.out.println("foo"); %>
</body>
</html>
and I want stop this page execution when I close browser, before session expiration.
My idea is to use JavaScript to catch onunload
event, use AJAX to postback the thread id to a servlet/another JSP, and brutally kill the thread after some time, i.e. 15s.
Is this correct? Is it possible? Any better idea?