I would like to ask how can I change with JSP a value of a database table when the user closes the browser? Thanks!
Asked
Active
Viewed 265 times
-1
-
This is a theoretical question, or you have your source? – Ashot Karakhanyan Feb 16 '14 at 11:41
3 Answers
1
You can handle the event onbeforeunload then make an asynchronous request to the server.
<script language="javascript">
function onbeforeunloadHandler() {
// AJAX code here
}
</script>
<body onbeforeunload="onbeforeunloadHandler()">
</body>
1
try to catch window.onclose event and send some request to server, see also:
0
You should handle window close event via javascript in browser and send asynchronuous request to the server. The url request handler should be servlet, register new or use existing. It may work but wrong solution to write some java code in JSP to handle the request and make changes in database.
Arsen Alexanyan
- 2,975
- 5
- 24
- 42