Lets make IT better by sharing the solutions

Thursday, January 22, 2009

achieving multilingual support in non struts application

I use ZKas front end framework. In our application we need to have internationalization which i had already done in struts by overriding the methods of controller servlet.
But Here no such methods when we use JSP's or ZK pages i.e., ZUL. Even when i tried to get the content of textbox on the other page it shows junk characters.While saving in database it saves as set of ??? .
There are few mandate to achieve multilingual support to your java applications.
1.) The Request should be able to sent multilingual data i.e., in UTF-8 format.
2.)The view part such as JSP should be able to show the UTF-8 characters.
3)The database should suport UTF-8 format.

Here is the way to do this:
I have
Database: MYSQL 5.0
Server: Tomcat 6.0
JDK: 1.6
For achieving sep 1:
Add URIEncoding="UTF-8" attribute in node so that it look like

port="8081"
protocol="HTTP/1.1"
redirectPort="8443"
URIEncoding="UTF-8" />

For achieving sep 2:
set page encoding as UTF-8

or for JSP's
it is:<%@page contentType="text/html" pageEncoding="UTF-8"%>
For achieving sep 3:
Set default-character-set to utf8 in MySQL\MySQL Server 5.0\my.ini file
default-character-set=utf8


Hope this might help