} This should set the character encoding of the response to that of the request (I'm using cyrillic strings in the output jsp page). For some reason, however, it does not work. It does not work, either, when I try to set the locale explicitly (like response.setLocale(new Locale("BG", "")); ) I have tried using a standing stream, too (in order to call response.getWriter() in the filter and use the obtained PrintWriter after chain.doFilter. Guessed already? :-) Right, it does not work (but produces a different non-working result - the should-be cyrillic texts now consist entirely of ?'s). Actually, the only thing I need is a way to tell the target browser which encoding to use, like the <%@ page contentType=" " %> directive. Is there a way to do that from inside the filter/servlet, based on a Locale object?
Have you tried using response.setContentType("text/html; charset=UTF-8") ? This tells the browser what encoding the response is in via the charset directive. I guess response.setLocale() should also set the appropriate encoding, but I'm less confident of it as compared to setContentType().
Joined: Jun 14, 2002
None of the response.set... methods work. I currently write <%@ page contentType="text/html; charset=UTF-8" %> on the top of every page, so I don't urgently need an answer to the question I posted, but I spent some time researching it with no success, so I thought somebody here might know. After all, a single line of code in an already existing filter looks much finer than a single line of code in EVERY jsp page :-) I guess the problem boils down to the servlet container I am using - Tomcat 4.0. Catalina is still under development, after all.