• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Internationalization

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi....
Can anyone please help the following:
- When a servlet handles request from client platform of multiple different language and locale, what is the encoding of the returned string when we do a (String)request.getParameter("XX")?
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am not sure if I interpreted your question correctly
Anyway, to determine the encoding of a request just call the getCharacterEncoding() method of ServletRequest. The returned value should be a a valid character encoding.
 
boon boh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Considering the various possible client platform's regional setting and the various languages input mechanism for http "form" data, is there a standard encoding used for the submitted data such that the webserver do not have to worry about the handling the client's data encoding differences?
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use the following
request.setCharacterEncoding("UTF-8")
 
boon boh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do we know the the data coming from client is "UTF-8" encoded? is it a default encoding for all http request?
 
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thuogh due to version problem of servlet.jar i never used, method setCharacterEncoding ... but here is how I went:
In every JSP page, I used UTF-8 encoding
<%@ page language="java"
contentType="text/html;charset=UTF-8">
[or alternatively you can achieve this by, using response.setContentType("text/html;charset=UTF-8") in servlets] and when u will submit any request from these pages(UTF encoded), though your servlet *will receive the request in UTF-8, but still params in request undergoes some change as each of them tend to get "0" i.e. leading zero's appended ... !!!
Hence before any operation, use
new String(request.getParameter(String).getBytes(strEncodingSrc));
where strEncodingSrc = encoding of box where application is running ... for windows
"ISO8859-1" .
Hope this helps !!!
 
Rototillers convert rich soil into dirt. Please note that this tiny ad is not a rototiller:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic