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")?
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.
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?
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