views:

36

answers:

1

When I add a Filter to a particular JSP file, the Arabic characters in the output appears like ???, even when the page encoding is been set to UTF-8 by <% @page pageEncoding="UTF-8"%> and <% response.setCharacterEncoding("UTF-8");%>.

The strange thing is, before I added the Filter, the output of all Arabic pages appears with correct encoding. Can someone tell how this problem is caused and how I can solve it?

+3  A: 

The filter is either directly or indirectly commiting the response and/or accessing the Writer or OutputStream of the HttpServletResponse which causes that the encoding cannot be changed anymore in the JSP. Fix the code in the filter accordingly. The filter should in any way not be writing anything to the response body. There the JSP (for HTML) or Servlet (for other content) is for.

By the way, you don't need to call <% response.setCharacterEncoding("UTF-8");%>. The <% @page pageEncoding="UTF-8"%> already implicitly does that.

BalusC
Thaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaank u Mr BalusC
Alaa
You're welcome :)
BalusC