Search code examples
jsputf-8metahtml4

What happens to the jsp page not supporting utf8 characters for html text field


I am using the following code to support UTF-8 in jsp. Please look at this :

JSP Code : editDistList.jsp

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

But when response is sent over the server with the post parameter (see the screenshots below), the value is not save in UTF-8 for that particular text and it displays other characters. I am using αβγδεζηθ characters (taken help from http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_script_charset ) but it displays αβγδεζηθin "ISO-8859-1".

enter image description here

enter image description here

I don't know why i am getting the garbage characters. I need to get UTF-8 characters which i have entered in text field somewhere. The static text displayed on same jsp page are displayed well. I used native2ascii to convert those characters to unicode-escape characters. But the problem is with dynamic text.

Please help..


Solution

  • You insert

    <meta charset="UTF-8"/>
    

    into <head></head> pair tags.

    Or you use this template for *.jsp files:

    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    
    <html>
    
    <head>
        <title></title>
        <meta charset="UTF-8"/>
    </head>
    
    <body>
    <%--Contents--%>
    </body>
    
    </html>