-
1. Re: @WebServlet - encoding - @MultipartConfig?
rsoika Oct 8, 2015 12:51 PM (in response to rsoika)I found this thread Rich:fileUpload and character encoding describing the same problem.
Currently I am running on Wildfly 9.0.1 And adding
<default-encoding>UTF-8</default-encoding>
to jboss-web.xml did not solve the problem.
Only translating the filename with:
fileName = new String(fileName.getBytes("iso-8859-1"), "utf-8");
did result in the correct format. But I don't think that this is a platform neutral solution? :-/
===
Ralph -
2. Re: @WebServlet - encoding - @MultipartConfig?
rsoika Oct 8, 2015 1:38 PM (in response to rsoika)I now try to solve the problem by guessing the ISO-8859-1 encoding
byte fileNameISOBytes[] = fileName.getBytes("iso-8859-1"); String fileNameUTF8 = new String(fileNameISOBytes, "UTF-8"); if (fileName.length() != fileNameUTF8.length()) { // convert to utf-8 logger.fine("filename seems to be ISO-8859-1 encoded"); fileName = new String(fileName.getBytes("iso-8859-1"), "utf-8"); }
A little bit ugly but it works on Wildfly and GlassFish.
-
3. Re: @WebServlet - encoding - @MultipartConfig?
rouvas Oct 8, 2015 3:04 PM (in response to rsoika)Try to set this:
request.setCharacterEncoding("UTF8");
in your servlet before actual processing of the request.
-
4. Re: @WebServlet - encoding - @MultipartConfig?
rsoika Oct 8, 2015 5:07 PM (in response to rouvas)setting
request.setCharacterEncoding("UTF8");
was my first try. But this have had no effect. The problem is that the header is receifed and processed by undertow in ISO-8859-1 encoding instead of UTF-8, as expected.