tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markus Schönhaber <mailing-tomcat-u...@schoenhaber.de>
Subject Re: Encoding in Tomcat 6
Date Mon, 21 May 2007 21:24:36 GMT
hkml@dfki.uni-kl.de wrote:

> Markus Schönhaber wrote:
>  > Works fine for me.
> Well, that is really a surprise for me. I tried this in 3 different 
> operating systems and it was consequently wrong.

That, in turn, doesn't surprise me, since...

>  > You do call response#setContentType before response#getWriter, don't you?
>  > There's no filter changing things?
> Well, the code is more or less trivial: the class extends HttpServlet 
> and overwrites method doGet like this:
> 
> @Override
>      protected void doGet( HttpServletRequest request,
>                            HttpServletResponse response )
>          throws ServletException, IOException
>      {
>          response.setContentType( "text/html;charset=UTF-8" );
>          response.setCharacterEncoding( "utf-8" );
> 
>          ServletOutputStream out = response.getOutputStream();

... ServletOutputStream is "suitable for writing binary data in the
response" as the docs say. If you want to transmit textual data, use
HttpServletResponse#getWriter() (see my question above).

Regards
  mks

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message