Search code examples
javahtmljspcharacter-encodingstripes

Malformed Farsi Or Arabic characters on Stripes


I am using Stripes framework to develop a web application.I want to be able to use Farsi or Arabic characters in web pages. I used

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

inside <head> tag of layout_main.jsp but it didn't work for me.

Also I had a look at http://confluence.atlassian.com/display/DOC/Configuring+Tomcat%27s+URI+encoding but still didn't work.

When I use <s:layout-render> this problem occurs,meaning that If I don't use stripes layout by

<%@taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld"%>

there is no problem to use Farsi characters.Is there any way to use stripes layout by stripes.tld and not having problem in Farsi characters?

Any help is appreciated.


Solution

  • Using that <meta> tag has totally no effect whenever the page is served over HTTP. You need to set the charset in the HTTP response header instead. Add the following to top of your JSP to achieve that:

    <%@page pageEncoding="UTF-8" %>
    

    As a bonus, it'll also instruct the server to write out those characters in the given encoding.

    See also: