Arguments against using ServletResponse.setLocale()
|by Anton Tagunov|
According to the spec calling ServletResponse.setLocale() should affect the character encoding (charset) setting of the HTTP response.
In my experiments on both Tomcat and Bea Weblogic 6.0sp1 calling either of
in a servlet had the only effect of having one of
But the Content-Type HTTP response header did not reflect the language and neither did the configuration of the writer that response.getWriter() returned.
On the other hand I do not feel upset about this. Anyway for many langueages, like Russian or Japanese multiple character encodings are applicable, while setting the character encoding from a locale assumes only one character encoding per language.
To say more, the servlet engine might choose a completely unappropriate character encoding for a given language. For examples, it looks like Jetty chooses iso-8859-5 character encoding for russian locale, while this character encoding is in fact exoctics and out of use.
Anyway the author of this article would be interested to hear other opinions and to know if the ServletResponse.setLocale() really does/does not set the character encoding on servlet engines other then Tomcat/Weblogic with non-european langueages. Any feedback is welcome :-).