下面是一个IE发送异步请求的页面,welcome.jsp
<%@ page language="java" import="java.util.*"
contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
out.println(new Date());
%>
<script language="JavaScript">
//读文件
function readFile(filename) {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.OpenTextFile(filename, 1);
var s = "";
while (!f.AtEndOfStream)
s += f.ReadLine() + "/n";
f.Close();
return s;
}
var fso, f, s;
fso = new ActiveXObject("Scripting.FileSystemObject");
f.Close();
}
writeFile("e:\\0.txt", "hello world");
function createXMLHttpRequest() {
var xmlHttp;
if (window.ActiveXObject) { //IE浏览器
//IE浏览器(将XMLHttpRequest对象作为ActiveX对象来创建)
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
}
}
} else {//非IE浏览器(将XMLHttpRequest对象作为本地浏览器对象来创建)
xmlHttp = new XMLHttpRequest();
}
if (xmlHttp == null) {
alert("不能创建XMLHttpRequest对象");
return false;
}
return xmlHttp;
}
var xmlhttp = createXMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
alert(xmlhttp.responseText);
}
};
xmlhttp.open("GET","/servlet/edu.rice.rubis.servlets.RegisterUser?firstname=aaaaaa&lastname=aaaaaa&ni
ckname=aaaaaaa&email=aaa@aa.com&password=aaaaaa®ion=AZ--Phoenix",true);
xmlhttp.send();
</script>
</body>
</html>