Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Encoding question

 
Bhushan Jawle
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to display data from database (Shift_JIS format) on a JSP. The data being displayed is garbage as encoding of page is Western European, fair enough.
If I change the encoding of page by <@page > directive of main page(which includes other jsps) to shift_jis, the encoding is set properly but data is still garbage.
If I display data by not setting encoding of main.jsp to shift_jis, it takes default encoding as Western European and displays garbage as mentioned earlier, however, if I change the encoding of browser to Shift_JIS (by browser menu)the data is displayed correctly. I am a bit confused as how is browser menu setting encoding different from setting it in JSP.
The data being displayed if from a session scoped bean which is populated by servlet.
I am not sure about where does the problem lie(I tried reconstructing string in bean by specifying str.getBytes(), "SJIS") but didn't work.
Regards,
Bhushan
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried getting the jsp to define the encoding and set the browser to "Auto-Select" the encoding rather than specifying anything?
Dave
 
Bhushan Jawle
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I forgot to mention that I have tried setting browser to auto-select.
In case I specify the setting in main.jsp it does select proper encoding when the composite page is displayed, however data displayed in corrupt, but when I don't specify the encoding, get the data and change page encoding by right click on page the data is displayed correctly, I wonder whether this has got something to do with the timing as theoritically both should have same effect.
Thanks for youy suggestion anyway David.
Regards,
Bhushan
 
Bhushan Jawle
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just found out soln. to my problem. The string was getting corrupted in XML parser, so by reconstructing string there as new String(stringBeingUsed.getBytes(), "Shift_JIS") solved the problem
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic