Ok, I have spent three seven hours googling and testing and I give up, I have to ask for help. I used to develop in Linux and everything was easy, now I use windows and such easy thing like setting correct locale does not work.
I created simple JSP with form:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<form action="save-user" method="post">
Name: <input type="text" name="name"><br>
Email: <input type="text" name="email"><br>
<input type="submit" value="Save">
</form>
And Servlet:
String name = request.getParameter("name");
String email = request.getParameter("email");
I receive LeoÅ¡ instead of Leoš. I use WildFly 8.0RC1, Windows 8 czech, firefox.
What I tried already:
- request.setCharacterEncoding("UTF-8"); before reading first parameter
- Filter with request.setCharacterEncoding("UTF-8");
- JVM property -Dfile.encoding=UTF-8
- Remove standard JEE stack jars from war
- Fix war packaging
- Split project to WEB and EJB module
When JPA entity / DAO is deployed then diacritics is mangled. If I comment out entity from servlet and remove JPA entity from war (currently remove OAuthLoginEJB.jar from WEB-INF/lib), then I receive correct encoding. If I add this EJB back then it fails again. Is it JBoss / WildFly bug?
I can provide complete sources: https://drive.google.com/file/d/0B-adlc5KThQDWTdYOEwxOUpTVEU/edit?usp=sharing It is ready to run, you do not even need to type czech letters, as they are prefilled. Thank you