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=FCngliche 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
>=20
> 2010/6/1 Manny Mondeo <mannynab@yahoo.com>:
> > =A0=A0=A0=A0=A0=A0=A0=A0 =
httpRes.setContentLength(content.toString().length());
>=20
> 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).
>=20
> > =A0=A0=A0=A0=A0=A0=A0=A0 httpRes.setContentType( "text/html; =
charset=3DUTF-8" ) ;
> > =A0=A0=A0=A0=A0=A0=A0=A0 out.write(content);
> > =A0=A0=A0=A0=A0=A0=A0=A0 out.flush();
> > =A0=A0=A0=A0=A0=A0=A0=A0 out.close();
> >
> > =A0=A0=A0=A0 }
> >
>=20
> Best regards,
> Konstantin Kolinko
>=20
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

Mime
View raw message