How can i send a json object to server?
Added by Everton Fonseca over 5 years ago
I want to send many datas of type json to my jwt, is that possible?
Replies (7)
RE: How can i send a json object to server? - Added by Wim Dumon over 5 years ago
Hi Everton,
The simple answer is 'yes, sure'. But for a helpful answer, I need more information on what you want to do ;-)
Wim.
RE: How can i send a json object to server? - Added by Everton Fonseca over 5 years ago
I would like to send data from an external application to my jwt server, and thus receive and reposonder back a new data to it.
RE: How can i send a json object to server? - Added by Wim Dumon over 5 years ago
Hello Everton,
Assuming that you want to send the data over HTTP to a fixed URL, you will have to deploy a global WResource at that URL. By reimplementing handleRequest(), you will be able to communicate with the external application.
You can deploy a global WResources by calling WtServlet.addResource().
Best regards,
Wim.
RE: How can i send a json object to server? - Added by Everton Fonseca over 5 years ago
Wim why request.getInputStream() always is empty when application sends a json to server jwt?
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");
}
RE: How can i send a json object to server? - Added by Everton Fonseca over 5 years ago
Wim why request.getInputStream() always is empty when application sends a json to server jwt?
RE: How can i send a json object to server? - Added by Everton Fonseca over 5 years ago
Qt Example Application send json to server jwt.