6 Replies Latest reply on Jul 2, 2012 3:20 AM by Eugene Ivlev

    Reading messages from properties file in UTF-8 on JSF 2.0 page

    Eugene Ivlev Newbie

      I have a problem with displaying messages on JSF 2.0 page in correct encoding. I store my messages files (messages.properties and messages_ru.properties) in UTF-8 encoding.

      In faces config I have following settings:



      In the class ru.dpop.auto.i18n.Messages I read properties.file:

      bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8")


      My JSF page have following structure:

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      <html lang="#{localeBean.language}" xmlns="http://www.w3.org/1999/xhtml"
      <f:view locale="#{localeBean.locale}">
              <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />


      But I instead of expected russian symbols I see something like this: Ð&#155;огин


      I explored this problem and found that I see ISO-8859-1 presentation insteand of UTF-8. My simple test:

      String input1 = new String("Логин");
      String input2 = new String(input1.getBytes("UTF-8"), "ISO-8859-1");
      System.out.println(input2); // Output Ð&#155;огин



      My question is - what I do wrong? Where is my error?


      I use JBoss AS 7.1.1 on Windows.

      But if I deploy this code to OpenShift - all work as expected!


      N.B. If I inject Messages instance in any bean and get message through messages.getObject("someText") I see correct value