<HTML>
<HEAD>
<script>
function test()
{
var xmlHttp,strData;
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.open("post","http://130.54.1.10:7001/unicom/StatusServlet",false);
xmlHttp.send();
strData=xmlHttp.responseText;
form1.age.value=strData;
document.all("div2").
document.all("div1").innerHTML=strData;
setTimeout("test()",3000);
}
</script>
<TITLE> New Document </TITLE>
</HEAD>
<BODY οnlοad="test()">
<form name="form1" action="">
<input type="text" name="age" size="15">
</form>
<div id="div1">
</div>
</BODY>
</HTML>
在对应的servlet中,对头文件的设置很重要,可以去掉缓存里面的数据。
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setHeader("Pragma","no-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
response.setContentType("text/html;charset=gb2312");
}