I have a servlet which should reply to requests in Json {obj:XML}
(meaning a Json containing an xml object inside).
The XML is encoded in UTF-8 and has several chars like => पोलैंड
.
The XML is in a org.w3c.dom.Document
and I am using JSON.org library to parse JSON. When i try to print it on the ServletOutputStream
, the characters are not well encoded. I have tested it trying to print the response in a file, but the encoding is not UTF-8.
Parser.printTheDom(documentFromInputStream,byteArrayOutputStream);
OutputStreamWriter oS=new OutputStreamWriter(servletOutputStream, "UTF-8");
oS.write((jsonCallBack+"("));
oS.write(byteArrayOutputStream);
oS.write(");");
I have tryed even in local (without deploing the servlet) the previous and the next code :
oS.write("पोलैंड");
and the result is the same.
Instead when I try to print the document,the file is a well formed xml.
oS.write((jsonCallBack+"("));
Parser.printTheDom(documentFromInputStream,oS);
oS.write(");");
Any help?