Search code examples
javaservletsglassfish-3

Java Servlets how to display the chinese Language in the result page?


We have a data's in the database with chinese and english language. Using java servlets i want to display the chinese data's in the page.

using SQL_JDBC_DRIVER select the chinese value and display in the result page

while (rs.next()) {
            vendorname = rs.getString("vendorname_cn");                 
            }           

        } catch (Exception e2) {
            System.out.println(e2);
        }
        out.print(vendorname);

in the page its shows like ????????? Expected value(from database) : 郑其蔚

let me know how can i display/print the exact chinese language in the page

IDE: netbean
Server : GlassFish

Solution

  • I have missed to set the content type, its working as expected once i set the content type.

    response.setContentType("text/html;charset=UTF-8");