JSP: how to read unicode from forms

April 6th, 2008
Are you having encoding problems while trying to read multilingual data from a JSP form? That is because JSP by default is trying to interpret your input as ISO-8859-1. That's fine unless you have a form that sendsUTF-8.

The problem can be eliminated by simply adding the following line of before you do any calls to getParameter():

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
...
request.setCharacterEncoding("utf-8");
...
}


Leave a Reply