user2882496
user2882496

Reputation: 3

Xpage read JSON context - http POST request

I'm trying to read java generated JSON stream created by out.writeBytes with my Xpage. I can get data like getServerPort and others (listed in code below) but when I'm trying to read context with BufferedReader or ServletInputStream I'm reciving errors. Any one knows simple way to read stream content like that on Xpage ? readLine method returned null.

    var exCon = facesContext.getExternalContext()
    var httpRequest:javax.faces.contex.ExternalContext =exCon.getRequest();

    print("CallCenter getContext "+String(exCon.getContext()))
    print("CallCenter ContentType "+String(httpRequest.getContentType()))
    print("CallCenter ContentLength"+String(httpRequest.getContentLength()))        
    print("CallCenter RemoteAddr "+String(httpRequest.getRemoteAddr()       ))
    print("CallCenter ServerPort "+String(httpRequest.getServerPort()))

    facesContext.responseComplete();

        //  ONE OF METHODS I've TRIED =============
         var stringBuffer:java.lang.StringBuffer = new java.lang.StringBuffer(80);
         var line = null;                 
         var reader:java.io.BufferedReader = httpRequest.getReader();
         while ((line = reader.readLine()) != null)
          {
            stringBuffer.append(line);
            stringBuffer.append("\n");
          }       
             print("Buffer "+stringBuffer.toString());

           // ============================


    } catch(e) {

    _dump(e);

fdf

Upvotes: 0

Views: 874

Answers (1)

stwissel
stwissel

Reputation: 20384

There can only be one: the stream or the reader. Instead of getReader() use new InputStreamReader(in); point in to the inputstream of the context

Upvotes: 1

Related Questions