XML data into database problem


Hi experts,
  I am getting value from xml which has encoding UTF-8, ex.
  Take Advantage of abc’s NYC ‘Bike Room’   .
After inserting it into oracle db, I am getting value
  Take Advantage of abc.s NYC .Bike Room   .
While displaying on JSP page
Take Advantage of abc HSBCs HSBCs sBike Rooms

How to solve this?
karan
LVL 11
ManishLeadAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
You need to set the oracle encoding to UTF8
0
 
CEHJCommented:
You need to have a font installed capable of reproducing those characters and you need to set your JSP to the correct character encoding
0
 
ManishLeadAuthor Commented:
I am storing xml value in java class.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
ManishLeadAuthor Commented:
IN JSP, I have this...
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
0
 
CEHJCommented:
Is your JSP publicly accessible?
0
 
ManishLeadAuthor Commented:
>> Is your JSP publicly accessible?
   Didnt get u?
 
I am showing on JSP above String from database, its look like above ..



0
 
CEHJCommented:
Can we connect to it?
0
 
ManishLeadAuthor Commented:
No, its not accessible to outside.

0
 
CEHJCommented:
Hard code some html with the same encoding setting and characters and see if they appear correctly
0
 
ManishLeadAuthor Commented:
Why it oracle db has above value after inserting..
Take Advantage of abc.s NYC .Bike Room  instead of
Take Advantage of abc’s NYC ‘Bike Room’
0
 
ManishLeadAuthor Commented:
I directly hardcoded above value in HTML , it is showing correctly,
Problem I think storing in db and getting it..
karan
0
 
ManishLeadAuthor Commented:
>> You need to set the oracle encoding to UTF8
How?
0
 
CEHJCommented:
Make sure db encoding set to utf8
0
 
CEHJCommented:
Run the following query and post the result:

select parameter, value from nls_database_parameters where parameter=NLS_CHARACTERSET';
0
 
CEHJCommented:
Missing quote sorry

select parameter, value from nls_database_parameters where parameter='NLS_CHARACTERSET';
0
 
ManishLeadAuthor Commented:
NLS_CHARACTERSET               US7ASCII
0
 
CEHJCommented:
There you are - it's wrong. It should be UTF8
0
 
ManishLeadAuthor Commented:
how to make it UTF-8?
0
 
CEHJCommented:
Check your Oracle docs for your particular version
0
 
ManishLeadAuthor Commented:
This we have database side option.
Is there any way we can do in java , if above charset is not going to change in db.?
karan
0
 
CEHJCommented:
You can't save those right and left quotes in ASCII - they don't exist
0
 
ManishLeadAuthor Commented:
can we change it and store it in db? so that output would be same.
0
 
CEHJConnect With a Mentor Commented:
Probably best to replace those characters with their ASCII counterpart before you insert into the db:

s = s.replaceAll("[\u2018\u2019]", "'");
0
 
ManishLeadAuthor Commented:
This may be only for one character,
   Can I make it general code so that any other such special character can be inserted in db
properly.
karan
0
 
CEHJCommented:
Not easily - UTF-8 supports thousands of characters, ASCII only a maximum of a couple of hundred. You need to set up the db encoding to receive the input it's getting
0
 
ManishLeadAuthor Commented:
I am using
string.getBytes("ISO-8859-1"),"UTF-8" to change ISO-8859-1 to UTF-8.
It is working fine , but on some machine , jsp showing french character corrupted.
ex. "'édition bannière étiolée sûrement déjà  celui là "

Just for info.
I am using JSTL in jsp.
charset is UTF-8
Also I m using fmt for setLocale etc.
 
0
 
ManishLeadAuthor Commented:
all,
    I increased the points of question, so anybody try to give answer.
karan
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.