Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    179
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Display international language characters in JSP

    IE 8 and Firefox 21. Tried to display international characters (such as Chinese characters along with the English characters) in a JSP.

    I copy a Chinese character and pasted in a input field. It looks as it should be at first. Then I save it to the database (Oracle 11 and set to AL32UTF8 to handle multi-byte characters). Next retrieve the text and display it in a jsp. Now the character becomes the garbage character.

    The JSP is set to

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

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <form id="frm" action="testPage.htm?cmd=loadPage&pageName=home" method="post" enctype="multipart/form-data" acceptCharset="UTF-8">


    How to solve the problem?

  • #2
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,276
    Thanks
    28
    Thanked 272 Times in 266 Posts
    Quote Originally Posted by otnj2ee View Post
    How to solve the problem?
    Verify that your document is displayed with the correct encoding: open Mozilla Firefox, open the page, right-click the page, select View Page Info. The document should indicate that the encoding used is UTF-8.

    If it's not, you should configure your server to output the correct HTTP headers: Content-Type: text/html; charset=utf-8. HTTP headers are more authoritative than a meta element and is the most correct way to specify the character encoding.

    If that's not the issue, then I'd imagine you have (A) multiple conflicting meta elements, (B) your page is being encoded as something other than UTF-8 (declaring that a document is encoded as UTF-8 when it's actually encoded as something else isn't going to help you), or (C) your database is not configured correctly.
    For every complex problem, there is an answer that is clear, simple, and wrong.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •