在asp中可以使用下面的方法创建服务器端xmlhttp对象:var oReq, strA
oReq = Server.CreateObject("MSXML2.ServerXMLHTTP");
oReq.open "POST",URL,false
oReq.setRequestHeader "Content-Length",Len(strA)
oReq.setRequestHeader "CONTENT-TYPE","application/x-www-form-urlencoded"
oReq.send strA请问在jsp中如何创建这个对象,或者有什么其他的方法实现同样的功能?

解决方案 »

  1.   

    <script >
    function content(){
    xml = new ActiveXObject("Microsoft.XMLHTTP");
    var post=" ";//构造要携带的数据
    xml.open("POST","ajax1.jsp?"+new Date().getTime(),false);//使用POST方法打开一个到服务器的连接,以异步方式通信
    xml.setrequestheader("content-length",post.length);
    xml.setrequestheader("content-type","application/x-www-form-urlencoded");
    xml.send(post);//发送数据
    var res = xml.responseText;//接收服务器返回的数据
    idi.innerHTML=res;
    <%--window.setInterval("content();",5000);--%>
    }