So here is my html code:
<!doctype html>
<html lang="fr">
...
<form action="servlet" method="post">
<textarea name="content" rows="30" cols="80" spellcheck="false"></textarea>
<input type="submit" value="SEND" />
</form>
...
</html>
And then the servlet part
String content = request.getParameter("content");
System.out.println(content);
And the problem is that if I type “é” in my textarea, the result is printed as “?”. I may be an encoding problem but I can’t make it work. I tried to change the character encoding to UTF-8 in my jsp page and then add the following line to my servlet
request.setCharacterEncoding("UTF-8");
But it doesn’t change anything. What should I do ? Again, I am a beginner in JSP/Java EE.
Ok I finally got it working. I tried everything but still got ? instead of é and I suppose it may be my server fault as I don’t use Tomcat or whatever but an embedded Jetty, which configuration is not that clear.
So I use JavaScript to send my string properly encoded:
And on the server side I decode it with this little function: