Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6326669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:08:05+00:00 2026-05-24T17:08:05+00:00

On the internet i found a book called JSF 2.0 cookbook . I rode

  • 0

On the internet i found a book called JSF 2.0 cookbook.

I rode chapter 7(Internationalization) and i found it pretty simple, i tried everything there by my self, and all worked fine besides the use of characters from languages such as Russian, Arabic, Serbian…

The book says this:

A common problem when using Arabic, Chinese, Russian characters (and
so on) sounds like this: “I can type such characters in an inputText
component, but when I submit the form, the inserted text is displayed
in Unicode characters, instead of human readable characters. How to
fix this?”.
The solution is very simple. All you have to do is to write the
following line in your JSF page:

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

So that’s exactly what i did. I added that line at the very first line of code of my main JSF template. But it didn’t work.
What am i missing? all my localization property files are configured to use UTF-8:

enter image description here

Also i tried this line in my h:head tag:

<meta http-equiv="content-type" content="text/html;charset=utf-8"/>

What else do i need to be able to see text in my page writen in Russian,Arabic…
The only thing i see when i change to ru,ar or sr locales is text like this:

ÙØ¨Ø­Ø« ÙÙ ØµÙØ­Ø§Øª ÙÙÙØ© ÙÙØ³Ù

Update
After a while reading some articles on localization, i came to the conclusion that my app needs to do the conversions to be able to render the special characters(I dont like the solution of the scape characters in the properties file). I was following an example at this link: http://jdevelopment.nl/internationalization-jsf-utf8-encoded-properties-files/

I understand most of it, but when i try to do it in my app, i see i still see rubish on the browser. I tried in various ways, but none worked:

This is how i organized my files:

enter image description here

This is my faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>

<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">
    <application>
        <message-bundle>resources.application</message-bundle>
        <locale-config>
            <default-locale>en</default-locale>
            <supported-locale>en</supported-locale>
            <supported-locale>de</supported-locale>
            <supported-locale>it</supported-locale> 
            <supported-locale>es</supported-locale> 
            <supported-locale>fr</supported-locale> 
            <supported-locale>sr</supported-locale> 
            <supported-locale>ar</supported-locale>
            <supported-locale>ru</supported-locale>
        </locale-config>

        <!-- Localization files configuration -->
        <resource-bundle>
            <!-- Path to the file -->
            <base-name>resources.messages</base-name>
            <!-- Variable representation of the file -->
            <var>msgs</var>
        </resource-bundle>              
    </application>

</faces-config>

And this is a file i found on the link above, to be able to do the conversions:

package support;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Enumeration;
import java.util.Locale;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;

import javax.faces.context.FacesContext;

public class TextBunddle extends ResourceBundle {

    protected static final String BUNDLE_NAME = "resources.messages";
    protected static final String BUNDLE_EXTENSION = "properties";
    protected static final Control UTF8_CONTROL = new UTF8Control();

    public TextBunddle() {
        setParent(ResourceBundle.getBundle(BUNDLE_NAME,
            FacesContext.getCurrentInstance().getViewRoot().getLocale(), UTF8_CONTROL));
    }

    @Override
    protected Object handleGetObject(String key) {
        return parent.getObject(key);
    }

    @Override
    public Enumeration getKeys() {
        return parent.getKeys();
    }

    protected static class UTF8Control extends Control {
        public ResourceBundle newBundle
            (String baseName, Locale locale, String format, ClassLoader loader, boolean reload)
                throws IllegalAccessException, InstantiationException, IOException
        {
            // The below code is copied from default Control#newBundle() implementation.
            // Only the PropertyResourceBundle line is changed to read the file as UTF-8.
            String bundleName = toBundleName(baseName, locale);
            String resourceName = toResourceName(bundleName, BUNDLE_EXTENSION);
            ResourceBundle bundle = null;
            InputStream stream = null;
            if (reload) {
                URL url = loader.getResource(resourceName);
                if (url != null) {
                    URLConnection connection = url.openConnection();
                    if (connection != null) {
                        connection.setUseCaches(false);
                        stream = connection.getInputStream();
                    }
                }
            } else {
                stream = loader.getResourceAsStream(resourceName);
            }
            if (stream != null) {
                try {
                    bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
                } finally {
                    stream.close();
                }
            }
            return bundle;
        }
    }

}

I think the mistake is in faces-config.xml, but i dont know what is the way i should configure the file, to be able to see the localiced messages when in my pages i use comands like this one:

#{msgs.mainbaner}

This is what firebug says when i request a language change:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:08:06+00:00Added an answer on May 24, 2026 at 5:08 pm
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    

    That’s the JSP syntax. This makes no sense. You’re using Facelets which uses UTF-8 by default already.

    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    

    This is worthless if you’re serving the page over HTTP instead of opening from local disk file system.


    If you’re seeing garbage, then the problem is caused by something else. I’d suggest to take some time to get yourself through this article: Unicode – How to get the characters right?

    At least, the key points for JSF2/Facelets are:

    • Configure your IDE to use UTF-8.
    • Configure your DB/table to use UTF-8.
    • Properties files must be ISO-8859-1 and you have to use unicode escapes. But there’s for JSF a workaround in flavor of a custom ResourceBundle so that you can use UTF-8 in properties files.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this code on internet : Class Book{ Public: void operator()(int Counter) const
I read so many articles out there in the internet and found that to
In the book Fortran 95/2003 for Scientists and Engineers , there is much talk
I searched the internet and found examples for; How to click a button which
I am actually stuck in 3-tier structure. I surfed the internet and found two
While reading a book called Let us C I read that a function showbit()
I need to export a really large csv file(~100MB). On the internet I found
Possible Duplicate: HTTP 404 - File not found Internet Explorer V6 I was testing
I'm stumped I've looked all over the internet and found no real way to
I faced this question in interview. When I searched on internet I found different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.