• 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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

setting utf-8 in jsp  RSS feed

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have set the charset to utf-8 using following <%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
When I see the encoding in the "view" option of browser it shows utf-8 correctly ..but the multi lingual characters like chinese ones ..are shown as "???" in the screen.
Also i m using struts 2.0 , and as per struts site I tried setting it in the form level like this :
<form action="XXXXXXX" method="post" accept-charset="utf-8">
This didn't help , I tried putting a hidden parameter by name "charset" and set it to utf-8 ..as suggested in struts site as well.
please provide any suggestions here ..
thanks
 
Ranch Hand
Posts: 265
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you saving the jsp file with the double-byte characters?

If you're not actually saving the file with UTF-8 encoding, you will sometimes see the behavior you're describing.
 
Rancher
Posts: 42974
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are the characters themselves UTF-8 encoded? Is a font available that includes these Chinese characters?
 
D kukreja
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes , the characters are correct ..chinese font is also available.
setting DBCS while creating the jsp ? I didn't understand what do you mean by that.
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Do you have Chinese font in your machine ?. Just you open a chines language based website for testing purpose. Now you see the characters like "???" then you must install chines font in your machine.

Regards,
Suresh Kumar.K
 
Stevi Deter
Ranch Hand
Posts: 265
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The default character encoding for many programs is ANSI (for example, most MS Windows products from Notepad to Word), not UTF-8 or Unicode.

If you save the file with the incorrect encoding, the characters will not be shown correctly when you try to use UTF-8 encoding.

I have occasionally found this to be the cause of apparent encoding issues at a later stage in the process - the file looks OK in the original editing software, but as soon as the file is read by another program, the mismatch in encoding causes problems.

So check what your character encoding is for the file you're saving to verify if this is or is not the case.
 
D kukreja
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am saving the values in the DB2 columns. The column is saved as "漢字" , and is rendered as it is on the screen.
DB2 supports utf-8 already. So I need to set the encoding while posting the form ?
I have used <form> tag to set the encoding , as suggested in struts site.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!