I'm writing a jsp website in which I get a query from client. I have to normalize the encod开发者_运维技巧ing of the query, I mean I should change the query from its encoding to UTF-16. Because of that, I need to know the encoding of the client.
Does browsers send this information on the request ?
HttpServletRequest.getCharacterEncoding()
Since you are using jsp, you should try to use some usefull methods that java offers.
public Map getHeaderFields()
will give you a Map of all headers you are searching for..
Moreover you have:
String getContentEncoding()
Returns the value of the content-encoding header field.
String getContentType()
Returns the value of the content-type header field.
String getCharacterEncoding()
Returns the name of the character encoding used in the body of this request. This method returns null if the request does not specify a character encoding
精彩评论