index.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script language="javascript">
function detect(){
xml=new ActiveXObject("Microsoft.XMLHTTP");
var post="";
xml.open("POST","http://localhost:8080/xmlhttp.jsp",false);
xml.setrequestheader("content-length" ,post.length);
xml.setrequestheader("content-type" , "application/x-www-form-urlencoded" );
xml.send(post);
var res=xml.responseText;
list.innerText=res;
setTimeout("detect()",1000);
}
</script>
<body onload = "detect()">
test :
<a id="list" > </a>
</BODY>
</HTML>
xmlhttp.jsp
<%@ page language="java" contentType="text/html;charset=GB2312"%>
<%@ page import ="java.util.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<%
Random randor=new Random();
out.println(randor.nextInt());
%>
</BODY>
</HTML>
posted on 2006-11-17 12:43
robbin163 阅读(180)
评论(0) 编辑 收藏