Search code examples
servletsinternationalizationutfrequestdispatcher

unicode characters are not displayed when requestdispatcher.forward is used to redirect to a page


I my creating an application which supports English and Japanese languages. I'm using resource bundle and property files.

Problem is occuring when I use request dispacther to forward the request to another JSP file:

  RequestDispatcher rd1 = request.getRequestDispatcher("jsp/Update.jsp");
  rd1.forward(request, response);

The japanese characters are displayed as

????

But, when I directly open Update.jsp by providing complete path, the japanese characters are displayed as expected.


Solution

  • Remember that a JSP page is a HTML page with Java content inside of it.

    Have you included the japanese character set in the JSP?

    <META http-equiv="Content-Type" contentType="text/html; charset=EUC-JP" >
    <%@ page contentType="text/html; charset=EUC-JP" %>
    

    If this doesn't work, try doing this:

    request.setCharacterEncoding("UTF-8");
    

    before you forward the request