tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steffen Heil" <li...@steffen-heil.de>
Subject AW: slow servlet filter for ByteArrayOutputStream response Wrapper
Date Fri, 04 Jun 2010 08:39:16 GMT
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.kolinko@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 <mannynab@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-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

Mime
View raw message