java 如何实现Server.CreateObject("Microsoft.XMLHTTP")

来源:百度知道 编辑:UC知道 时间:2024/05/09 09:47:57
我有一段ASP代码,想用JAVA或JSP实现,如何写呢
formurl="http://59.42.247.55/http.php?t=332&name=LS220&pass=1245"
set http = Server.CreateObject("Microsoft.XMLHTTP")
http.Open "GET", formurl, false
http.setRequestHeader "Content-type:", "text/xml;charset=UTF-8"
http.Send
response.write(http.ResponseText)
set http = Nothing

如何用JAVA或JSP来写呢.

var xmlhttp;
function createXmlObject(){
if(window.ActiveXObject){
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();

}
}

创建xmlhttp对象;然后在调用方法得到这个对象

function handler(){
createXmlObject();
if (xmlhttp.readyState == 4) {// 收到完整的服务器响应 }
if (xmlhttp.status == 200) {//HTTP服务器响应的值OK}

xmlhttp_request.open('GET', url, true);

xmlhttp_request.send(null);
}

不懂asp