• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in displaying hindi contents in servlet,jsp?  RSS feed

 
Niranjan Singh Chouhan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to display hindi contents in servlet but it is displaying in following format-

निवासी. मैं ऊपर नाम साक्षी, सत्यनिष्ठा वाणी है और नीचे के रूप में घोषित:

I have tried to change pageEncoding, characterEncoding and contentType in both jsp and servlet but i haven't got success.

Please help me?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

1) How are you specifying the encoding?

2) How are you ensuring that the content in the page is actually in the encoding that you are specifying?

3) Does the machine where you are viewing have a font installed that contains those characters?

A good start might be to hand-craft an HTML page that displays the content correctly, before you start doing that dynamically via servlet and JSP.
 
Niranjan Singh Chouhan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) How are you specifying the encoding?
like below-
response.setContentType("text/html; charset=UTF-8");
response.setCharacterEncoding("UTF-8");

2)How are you ensuring that the content in the page is actually in the encoding that you are specifying

i am ensuring it by
response.getCharacterEncoding();

3) I am using linux machine and hindi fonts are not installed on it. but i am displaying contents in ckeditor and hindi fonts are installed in ckeditor.


Thanks.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2)How are you ensuring that the content in the page is actually in the encoding that you are specifying

i am ensuring it by response.getCharacterEncoding();

That just tells you what encoding your code has set, it does not say anything about what encoding the data actually is in. In particular, if the content is not in that encoding, then things will break. Where does the content come from? In what encoding is it there? Are you certain that along the way it is only treated in ways that preserve the encoding? Etc.

I am using linux machine and hindi fonts are not installed on it. but i am displaying contents in ckeditor and hindi fonts are installed in ckeditor.

I don't know ckeditor enough to say how it handles fonts. If this was my problem, I'd start by installing appropriate fonts system-wide.
 
Niranjan Singh Chouhan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hindi contents are coming from velocity template.
By using following code in a method of a class i am fetching template on servlet

Template t = ve.getTemplate( templateName );
return t;

and in servlet i am converting value of template object(which above code will return) into string using StringWriter.
English templates are working fine. having problem only with hindi contents.

Please suggest me a way so that i can go into right direction?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That doesn't really address the important points: is the content in UTF-8 everywhere? It apparently is not, since you mention Java Strings. How is the code handling encodings when these conversions take place?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!