Client:
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<html locale="true">
<head>
<script type="text/javascript">
Util = function() {
function getXRequest() {
activeX = ['MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP']
try {
http = new XMLHttpRequest();
} catch (e) {
for (var i = 0; i < activeX.length; ++i) {
try {
http = new ActiveXObject(activeX[i]);
break;
} catch (e) {
}
}
} finally {
return http;
}
}
return {
sleep : function(sec) {
xreq = getXRequest()
startTime = new Date()
while ((new Date().getTime() - startTime) < sec) {
xreq.open('GET', '/hellowar/sleep.jsp', false);
xreq.send(null);
}
}
}
}()
</script>
</head>
<body bgcolor="white">
<button οnclick="javascript:Util.sleep(10000);alert('Delay 10 Sec.')">click me</button>
</body>
</html>
Server:
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<html locale="true">
<head>
<script type="text/javascript">
Util = function() {
function getXRequest() {
activeX = ['MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP']
try {
http = new XMLHttpRequest();
} catch (e) {
for (var i = 0; i < activeX.length; ++i) {
try {
http = new ActiveXObject(activeX[i]);
break;
} catch (e) {
}
}
} finally {
return http;
}
}
return {
sleep : function(sec) {
xreq = getXRequest()
startTime = new Date()
while ((new Date().getTime() - startTime) < sec) {
xreq.open('GET', '/hellowar/sleep.jsp', false);
xreq.send(null);
}
}
}
}()
</script>
</head>
<body bgcolor="white">
<button οnclick="javascript:Util.sleep(10000);alert('Delay 10 Sec.')">click me</button>
</body>
</html>