Hi

I just read that reply and noticed that I have the same fault in my code.
How can I measure the length of the utf8-Encoding?

The only way I can think of is to convert the String to byte[] and the take
its length. However at that point it does not make any sense to use a
writer, it would be more suitable to use the OutputStream and send that
byte[], right?

Is there another way to get the correct content-length?

Regards,
  Steffen


> -----Ursprüngliche Nachricht-----
> Von: Konstantin Kolinko [mailto:knst.koli...@gmail.com]
> Gesendet: Dienstag, 1. Juni 2010 11:41
> An: Tomcat Users List
> Betreff: Re: slow servlet filter for ByteArrayOutputStream response
Wrapper
> 
> 2010/6/1 Manny Mondeo <manny...@yahoo.com>:
> >          httpRes.setContentLength(content.toString().length());
> 
> Also, the above, or simplier "content.length()", will give you the length
> measured in characters,  but Content-Length must be the length measured
> in bytes.  For a multi-byte charset such as UTF-8 those are certainly not
the
> same. (Unless all your characters are 7-bit).
> 
> >          httpRes.setContentType( "text/html; charset=UTF-8" ) ;
> >          out.write(content);
> >          out.flush();
> >          out.close();
> >
> >      }
> >
> 
> Best regards,
> Konstantin Kolinko
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to