This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Japanies Character Display Problem  RSS feed

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

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

pageContext.getOut().print(String);

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

Can any body help on same .
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!