Tomcat: проблемы с выводной кодировкой.
Поищи ответ впроблему это не решает.
Примечательно, что в томкате 4 работает, а в 6 - нет.
ЗЫ: через getWriter работает и в шестёрке. а вот через OutputStream - нет.

/**
* Writes a <code>String</code> to the client,
* without a carriage return-line feed (CRLF)
* character at the end.
*
*
* @param s the <code>String</code> to send to the client
*
* @exception IOException if an input or output exception occurred
*
*/
public void print(String s) throws IOException {
if (s==null) s="null";
int len = s.length;
for (int i = 0; i < len; i++) {
char c = s.charAt (i);
//
// XXX NOTE: This is clearly incorrect for many strings,
// but is the only consistent approach within the current
// servlet framework. It must suffice until servlet output
// streams properly encode their output.
//
if c & 0xff00) != 0) { // high order byte must be zero
String errMsg = lStrings.getString("err.not_iso8859_1");
Object[] errArgs = new Object[1];
errArgs[0] = new Character(c);
errMsg = MessageFormat.format(errMsg, errArgs);
throw new CharConversionException(errMsg);
}
write (c);
}
}
То, что это работало в Tomcat 4 не значит, что это было правильно там реализовано. Если можешь, используй Writer'ы.
Вот еще цитата в тему из JavaDoc на ServletResponse:
* To send binary data in a MIME body response, use
* the ServletOutputStream returned by #getOutputStream.
* To send character data, use the PrintWriter object
* returned by getWriter. To mix binary and text data,
* for example, to create a multipart response, use a
* ServletOutputStream and manage the character sections
* manually.
*
* The charset for the MIME body response can be specified
* explicitly using the setCharacterEncoding and
* setContentType methods, or implicitly
* using the setLocale method.
* Explicit specifications take precedence over
* implicit specifications. If no charset is specified, ISO-8859-1 will be
* used. The setCharacterEncoding,
* setContentType, or setLocale method must
* be called before getWriter and before committing
* the response for the character encoding to be used.
Оставить комментарий
yolki
есть сервлет, который печатает "превед":Вот что на выходе:
какие настройки где подкрутить?
Tomcat 6.0.14