• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Encoding question

 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Evil is afoot. But this tiny ad is just an ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic