Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 2nd, 2004, 06:01 PM
Authorized User
 
Join Date: Jun 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Http web request Nadeem ASP.NET 2.0 Professional 5 October 27th, 2008 07:28 AM
xml http request AaronT Ajax 0 May 29th, 2008 11:52 PM
request forwarging & request redirection hafizmuhammadmushtaq Servlets 2 April 24th, 2008 12:42 AM
HTTP request works sometimes deBassMan XML 0 June 1st, 2007 08:12 AM
HTTP Request. gilf Classic ASP Professional 0 March 18th, 2005 12:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.