Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Trouble in handling Internationalization

 
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I receive the http request in my servlet and since I have to provide support for kanji characters etc. before any processing I am converting the received request string into UCS encoded string with the bytes using UTF-8 encoding
like,
String ucsString = new String(_req.getParameter("string").getBytes(),"UTF-8");
But this works fine if I receive request from a browser having default encoding as "UTF-8" and it fails if the browser is having an encoding Western Europian "ISO" and surprisingly the _req.getParameter("string") only returns me correct string.
My application is in NT machine and jdk1.3
I am writing response.setContentType("text/html; charset=UTF-8")
Can anybody help me to solve the problem as I can't force user to change its default browser encoding to UTF-8.
Thanks in advance
Varun.
 
tumbleweed and gunslinger
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure what you're trying to do...
Are you saying that you are receiving posted UTF-8, but want to send a different encoding method in response?
Also, what type of response are you sending? Just translated pages?
If so, why not utilize a resource bundle and locale objects?
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,
My problem is solved as using response.setContentType("text/html; charset=UTF-8") , I added
<%page charset="text/html; charset=UTF-8"...%> in my jsp and the data was not lost.Thuogh I have still not understand why response.setContentType was not sufficient ...!!!

-Varun
 
reply
    Bookmark Topic Watch Topic
  • New Topic