views:

1046

answers:

1

I am migrating a struts application from Websphere to Tomcat 6 and my application has support for Russian language. In Websphere we use to pass the JVM param -Dclinet.encoding.override=cp1251 but when I tried this with tomcat by passing the JVM argument -DFile.encoding=cp1251, the system doesnt accept input (I an any text box like in search screen) and responds with invalid input.

I also tries passing the same parameter as of Websphere (-Dclinet.encoding.override=cp1251) but didnt solve my problem.

+3  A: 

You can use a servlet filter which sets the response encoding to workaround the problem. Check http://snippets.dzone.com/posts/show/5948. There is a sample code for the filter. You need to replace the: response.setCharacterEncoding("UTF-8"); and 'request.setCharacterEncoding("UTF-8");' with the required encoding. Also you can modify the sample to load the encoding from the filter config. After this you chain the filter to get all the requests.

zloster
Thanks a ton. Your response has been a great help!
prabhu