I have composed JSON response as below in my java servlet, where JObject is the JSON object created
response.setContentType("application/json; charset=UTF-8");
PrintWriter printout = response.getWriter();
printout.print(JObject);
printout.flush();
But it got received as text/plain in the receiving side
[Server: Apache-Coyote/1.1, ETag: W/"XXXXXXXXXX", Last-Modified: Tue, 04 Jun 2013 10:42:31 GMT, Content-Type: text/plain, Content-Length: 2573, Date: Tue, 04 Jun 2013 10:44:01 GMT]
How to get the exact JSON response?
If i compose the JSON
response in same machine, im getting the JSON data. But if i compose the JSON
response in another server, its returning back as text/plain
.
And this is the JObject
:
JSONObject JObject = new JSONObject();
JObject.put("Response", "1");
JObject.put("Message", "Client unauthorized");