I am using commons FileUpload to get client headers. I am trying to use the header Strings to write txt content like:
StringA; StringB; "ciryllic word"
The server localization is ru_RU.utf-8 the client is cp1251... The result is I always get on my client (desktop app)
StringA; StringB; ?????
instead of cyrillic characters in my server txt files lines. If I open txt with my IE 8 and watch the encoding the cyrillic content can be readable with utf-8 encoding only :( So my question is what should me do to make my servlet write ru_RU.utf-8 acceptable strings. I am testing it on windows so I need to know it for sure
Please help me to understand
Any useful comment is appreciated
ServletOutputStream out =response.getOutputStream();
out.write((YOUrfileasstring).getBytes("UTF-8"));
I might be misunderstanding the question, but to answer this part -
So my question is what should me do to make my servlet write ru_RU.utf-8 acceptable strings.
You should use either of two methods provided by the HttpServletResponse class. Those are:
setContentType(), eg
response.setContentType("text/html; charset=UTF-8");
or,
setCharacterEncoding(), eg
response.setCharacterEncoding("utf-8");
There are other examples for those methods and information on when to use them all over the place.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.