• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

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 !!!
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic