Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Japanies Character Display Problem

Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am writing a Tag handler to include a html file . While using Japanies
html I am getting the ?? character in genarated JSP in the IE .
Can anybody help me on how to write a string in JSP which contains Shift_JIS character using Java .

I have written a function which takes the file path of the html and returns the String in Shift_JIS character encoded .

public String readInput(String filepath) {
// This is working fine .
return String ;

Even if I am using java code to write in a disk file the characters are displaying correctly .
But when I want to write the returned string in JSP using following code


I am loosing the character encoding of Japanies and I am seeing them in JSP as ???

Can any body help on same .
Posts: 43016
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly, you'd need to specify that the file you're reading is in SHIFT_JIS, so that Java can correctly convert it to Unciode (which it uses internally). The InputStreamReader class has constructors that let you specify the encoding (use it with a FileInputStream).

Then it depends on what encoding you want to use for the JSP page. If it's Unicode, then you can just write the string to the output. If it's something else (like SHIFT_JIS), then once again you need to convert the string you have, e.g. by String.getBytes("SHIFT_JIS").

Make sure the JSP page sets the proper character set.
Do you want ants? Because that's how you get ants. And a tiny ads:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic