JSP & HTTP Server Request
I need to Load the entire HTTP Request into a variable, and be able to parse that variable.
Think:
Machine Sends an XML request to my JSP Site.
My JSP Site loads the entire XML Request into a String Variable (xmlString)
My JSP Site sets the value of other variables to equal certain elements now located in my xmlString variable.
How would I do this in JSP?
Here is the code I would use for ASP:
<script language=JScript RUNAT=Server>
function elementValue(xml, elem)
{
var begidx;
var endidx;
var retStr;
begidx = xml.indexOf(elem);
if (begidx > 0) {
endidx = xml.indexOf('</',begidx);
if (endidx > 0)
retStr = xml.slice(begidx+elem.length,
endidx);
return retStr;
}
return null;
}
</script>
<%
REM This command reads the incoming HTTP cXML Request
xml = Request.BinaryRead(Request.TotalBytes)
for i = 1 to Request.TotalBytes
xmlstr = xmlstr + String(1,AscB(MidB(xml, i, 1)))
Next
RequestNumber = elementValue(xmlstr, "<XMLELEMENT1>")
url = elementValue(xmlstr, "<XMLELEMENT2>")
fromUser = elementValue(xmlstr, "<XMLELEMENT13>")
%>
So at this point, my variables RequestNumber, url, and fromUser have values. I can go on doing my processing from there.
Mike S>
|