[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

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
0
Manish
Asked:
Manish
  • 14
  • 13
2 Solutions
 
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
 
ManishLeadAuthor Commented:
IN JSP, I have this...
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
CEHJCommented:
You need to set the oracle encoding to UTF8
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
 
CEHJCommented:
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 14
  • 13
Tackle projects and never again get stuck behind a technical roadblock.
Join Now