views:

140

answers:

1

Hi!

I have problem with setting proper charset on my jsf pages. I use MySql db with latin2 (ISO-8859-2 charset) and latin2_croatian_ci collation. But, I have problems with setting values on backing managed bean properties.

Page directive on top of my page is:

<%@ page language="java" pageEncoding="ISO-8859-2" contentType="text/html; charset=ISO-8859-2" %>

In head I included:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2">

And my form tag is:

<h:form id="entityDetails" acceptcharset="ISO-8859-2">

I've created and registered Filter in web.xml with following doFilter method implementation:

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    request.setCharacterEncoding("ISO-8859-2");
    response.setCharacterEncoding("ISO-8859-2");
    chain.doFilter(request, response);
}

But, i.e. when I set managed bean property through inputText, all special (unicode) characters are replaced with '?' character.

I really don't have any other ideas how to set charset to pages to perform well. Any suggestions?

Thanks in advance.

A: 

The logging I did was misleading. It turned out that stdout replaced special characters with '?' character. But, characters which were written to db were also replaced by '?' sign. The other part of the problem was that JConnector hasn't been set for correct encoding, so db entries looked very much like logged properties. I didn't realize that it was a combination of two problems.

Vladimir