Suppose the CGI header contains: content-type: text/plain; charset=shift_jis This content type is exactly set to the header of the servlet response. However, both the reader of the CGI output and the writer of the servlet output always apply the platform's default character encoding, since InputStreamReader and OutputStreamWriter are constructed without charset. I've already written the patch. Please contact me by email, then I can send you the revised CGIServlet (the source came from 5.5.15).
Created attachment 17811 [details] A revised CGIServlet based on Tomcat 5.5.15 source.
The revised code was attached. In order to solve this problem, the following steps are made. (1) charset is extracted from the content-type in CGI header. (2) servletContainerStdout is created for the specified charset if any. (3) commandsStdOut is created for the specified charset if any.
Fixed using an alternative patch that removed the Stream -> Reader -> Stream conversions that were causing the problem.