Why request.getInputStream() always is empty when application sends a json to server jwt?

Added by Everton Fonseca 12 months ago

WtServlet.getInstance().addResource(new WResource() {
@Override
protected void handleRequest(WebRequest request, WebResponse response) throws IOException {

ServletInputStream input = request.getInputStream();

System.out.println("Put int: " + input.available());
BufferedReader reader = new BufferedReader(new InputStreamReader(input));

String dado = null;

while ((dado = reader.readLine()) != null) {

System.out.println("Dados: " + dado);
}
input.close();

}
}, "/SGIB/index/input");

}


Replies (1)

RE: Why request.getInputStream() always is empty when application sends a json to server jwt? - Added by Koen Deforche 12 months ago

Hey,

The library already parsed the request, I believe. I am not sure if a dynamic resource can be used for this.
But is it not more common/convenient to use a plain servet for a JSON POST API?

Regards,
Koen

(1-1/1)