Saeed
Saeed

Reputation: 7370

How to get client Encoding?

I'm writing a jsp website in which I get a query from client. I have to normalize the encoding 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 ?

Upvotes: 0

Views: 266

Answers (2)

Gianpaolo Di Nino
Gianpaolo Di Nino

Reputation: 1147

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

Upvotes: 1

Related Questions