Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Struts and Farsi Language

  Asked By: Kenneth    Date: Mar 31    Category: Java    Views: 1341

i write a multilingual project
but , i have problem with farsi language...
i coded this line in the my JSP pages...
1-<%@ page contentType="text/html;charset=UTF-8"
language="java" %>
2- request.setCharacterEncoding("utf-8");
3-<meta http-equiv="Content-Type" content="text/html;

and :
in Jboss i set the URIENCODING to UTF_8

and my data in(MySql)is correct! but farsi carachters
is Wrong(in jsp pages)!?

i solve this problem by chnage my data format from
ISO-.. to UTF8 when i want save this data to
database.. but i think this sloution it is not good...
please help me that i find a good sloution for this problem..



1 Answer Found

Answer #1    Answered By: Gorkem Yilmaz     Answered On: Mar 31

You must define an encoding filter to process and set  encoding of
request's content.

public class RequestEncodingFilter implements Filter{

private String encoding;

public void init(FilterConfig config) throws ServletException {
encoding = "UTF-8";
String enc = config.getInitParameter("encoding");
if(enc !=null && enc.length() > 0){
encoding = enc;

public void destroy() {}

* <p>Dispatching specified request  changing its parameter's
* encoding. Struts applications generate pages  in utf-8. Then
* parameter of normal PC browser is in utf-8. That's why this
* handles it in utf-8. If some user agent works on different
* character encoding can be specified in web.xml, filter element.
* </p>
public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
throws IOException, ServletException {

chain.doFilter(request, response);

and then define it in web.xml

!-- Encoding Filter Configuration -->

Didn't find what you were looking for? Find more on Struts and Farsi Language Or get search suggestion and latest updates.