4 Replies Latest reply on Feb 12, 2008 2:25 PM by cxy007

    How to read byte array from a JSP page

    cxy007 Level 1
      I have a JSP page which return a zip stream for a Big String. I want to use HTTPService to read it to ByteArray and decompress it. But I can't find the right way to get the result. Always have some error.

      Anyone knows how to do it? Thanks!
        • 1. Re: How to read byte array from a JSP page
          Gregory Lafrance Level 6
          What is the error, and can you provide simplified sample code.
          • 2. Re: How to read byte array from a JSP page
            cxy007 Level 1
            I tried many things:

            var rawData:String = String(resultEvent.result);
            var byte:ByteArray=new ByteArray();
            byte.writeUTFBytes(rawData); // I also tried byte.writeUTF(rawData);
            byte.uncompress();
            var decoded:String=byte.toString();

            Besides, document says the result formats maybe:

            "object" The value returned is XML and is parsed as a tree of ActionScript objects. This is the default.
            "array" The value returned is XML and is parsed as a tree of ActionScript objects however if the top level object is not an Array, a new Array is created and the result set as the first item. If makeObjectsBindable is true then the Array will be wrapped in an ArrayCollection.
            "xml" The value returned is XML and is returned as literal XML in an ActionScript XMLnode object.
            "flashvars" The value returned is text containing name=value pairs separated by ampersands, which is parsed into an ActionScript object.
            "text" The value returned is text, and is left raw.
            "e4x" The value returned is XML and is returned as literal XML in an ActionScript XML object, which can be accessed using ECMAScript for XML (E4X) expressions.

            None of them is what I want, right? The only thing close is text.

            I tried base64, that works, which prove the uncompress part work. I just don't know how to get a ByteArray from a jsp page. I can only read text. :-(
            • 3. Re: How to read byte array from a JSP page
              Gregory Lafrance Level 6
              Maybe you can't use HTTPService. How about Socket, or URLStream.

              See these help topics:
              Converting data from Java to ActionScript
              URLStream
              Socket connections
              Using flashVars
              • 4. Re: How to read byte array from a JSP page
                cxy007 Level 1
                Thanks. I will take a look for that.