<%@page contentType="text/html; charset=Shift_JIS"%>
<html>
<head>
<title>equipment</title>
<script type="text/javascript" language="javascript">
var req;
//initialize request.
function initRequest(url) {
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.open("GET", url, true);
}
//start work
function work() {
//target servlet
var url = "equipmentservlet";
//initialize request
initRequest(url);
// set callback function
req.onreadystatechange = displayStatus;
//do
req.send(null);
}
function displayStatus() {
if (req.readyState == 4) {
if (req.status == 200) {
var i = 0;
var str = req.responseText;
if (str == null || str.length != 7) {
} else {
for (i = 0; i < 7; i++) {
var status = str.charAt(i);
setStatus(i, status);
}
}
setTimeout("work()", 6000);
}
}
}
function setStatus(i, status) {
var labelName = \'equipment_\' + i;
var idiv = window.document.getElementById(labelName);
if (status == \'1\') {
idiv.innerHTML = \'<font color="red">error</font>\';
}
if (status == \'0\') {
idiv.innerHTML = \'<font color="black">good</font>\';
}
}
</script>
</head>
<body bgcolor="#ffffff">
<h1>
設備
<br>
<table>
<tr>
<td>
設備 0
</td>
<td>
<div></div>
</td>
</tr>
<tr>
<td>
設備 1
</td>
<td>
<div></div>
</td>
</tr>
<tr>
<td>
設備 2
</td>
<td>
<div></div>
</td>
</tr>
<tr>
<td>
設備 3
</td>
<td>
<div></div>
</td>
</tr>
<tr>
<td>
設備 4
</td>
<td>
<div></div>
</td>
</tr>
<tr>
<td>
設備 5
</td>
<td>
<div></div>
</td>
</tr>
<tr>
<td>
設備 6
</td>
<td>
<div></div>
</td>
</tr>
</table>
</h1>
</body>
</html>
servlet主要部分: