js|xml| Interactive | data
1. Client Submission Request
Domain = "test.com"
sXml = "<?xml version=" "1.0" "encoding=" "gb2312" "?>" &_
"<Package>" &_
"<Domain>" & Domain & "</Domain>" &_
"</Package>"
Set OD = Server.CreateObject ("Microsoft.XMLHTTP")
Od.open "Post", " http://Server/Domain_Check.jsp", False
Od.send (SXML)
If od.status = MB Then
result = Od.responsetext
Set o = Server.CreateObject ("Microsoft.XMLDOM")
O.loadxml (Result)
Domain = CInt (O.selectsinglenode ("//result"). Text)
Response.Write Domain
Set o = Nothing
Set OD = Nothing
End If
2. Server-side parsing packets
<%@ page import= "java.util.*"%>
<%@ page import= "java.text.*"%>
<%@ page import= "java.io.*"%>
<%@ page import= "org.w3c.dom.*"%>
<%@ page import= "javax.xml.parsers.*"%>
<%@ page contenttype= "text/html; CHARSET=GBK "%>
<%
Get Packets
Request.setcharacterencoding ("UTF-8");
BufferedReader in = Request.getreader ();
String Line;
String xmlrequest = "";
String domain_name = "";
while (line = In.readline ())!= null)
{
Constructing packets
XMLRequest = xmlrequest + line + "\ n";
}
Documentbuilderfactory factory = Documentbuilderfactory.newinstance ();
Documentbuilder db = Factory.newdocumentbuilder ();
Bytearrayinputstream stream = new Bytearrayinputstream (xmlrequest.getbytes ("UTF-8"));
Document doc = Db.parse (stream);
Element root = Doc.getdocumentelement ();
NodeList domain = root.getelementsbytagname ("domain");
if (domain.getlength () = = 1) {
Element e = (element) domain.item (0);
domain_name = (String) e.getfirstchild (). Getnodevalue ();
}
Return data
Out.println ("<?xml version=\" 1.0\ "encoding=\" gb2312\ ">\n");
Out.println ("<package>\n");
Out.println ("\t<result>" + domain_name + "</result>\n");
Out.println ("</Package>");
%>
3. Get return results
test.com