[b]****The problem is solved*****[/b]
My observations in this exercise are:
1. Application server should encode the character in UTF-8 before sending them as request parameter.
2. Database should be compatible to accept the UTF-8 characters.
I have done following configurations in Application Setting and DB Setting:
1. Added sun-web.xml in in WEB-INF folder of Application .EAR file. Content of sun-web.xml are :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 8.0 Servlet 2.4//EN" "
http://www.sun.com/software/sunone/appserver/dtds/sun-web-app_2_4-0.dtd">
<sun-web-app>
<locale-charset-info default-locale="">
<locale-charset-map locale="" charset=""/>
<parameter-encoding default-charset="UTF-8"/>
</locale-charset-info>
</sun-web-app>
This makes server to enforce the character encoding to whatever you have set in sun-web.xml.
Even if you have already done this in my application (request.setCharacterEncoding(RfxApp.ENCODING_SCHEME);) will be ignored by the browser, so this setting is required.
You can do similar setting for other servers also. (Please update this post if you find something for Tomcat/Webspher and Weblogic)
You can achieve the same thing by adding filters also. One of such filter is provided by Spring Framework.
2. The second setting needed is at database level. (When I posted this query on the forum this part of DB setting was missed out, hence this thread...)
You need to set the encoding at DB level also, since I was using Western European character, UTF-8 covers this, so we need to set encoding as UTF-8 at db level.
My application was pointing to MySQL server I ran below query:
show variables like "%char%";
Which gave me result as:
Variable_name Value
------------------------ --------------------------
character_set_client - latin1
character_set_connection - latin1
character_set_database - utf8
character_set_filesystem - binary
character_set_results
character_set_server - latin1
character_set_system - utf8
If you observe that the DB character set is "latin1"
You need to change this to UTF-8. After that the output of same query was:
Variable_name Value
------------------------ -------------------------------------------------------
character_set_client - utf8
character_set_connection - utf8
character_set_database - utf8
character_set_filesystem - binary
character_set_results
character_set_server - utf8
character_set_system - utf8
After these settings my application started saving the € (Euro) Character in database
Thanks,
Nilesh Birajdar
[Message sent by forum member 'npbirajdar' (npbirajdar_at_yahoo.com)]
http://forums.java.net/jive/thread.jspa?messageID=363712