Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

RE: Can I change Tomcat's default character encoding?

Yansheng Lin

2004-05-27

Replies:

From Javadoc for OutputStreamWriter:

An OutputStreamWriter is a bridge from character streams to byte streams:
Characters written to it are encoded into bytes using a specified charset.
The charset that it uses may be specified by name or may be given
explicitly, or the platform's default charset may be accepted.

So the answer is verdor-specific. Of course, you can tell javac and java
runtime to use the desired encoding, but that's not fool-proof.

To do a conversion from one encoding to another, you can use the new
String(oldBytes, charset) constructor. You can implement that in your
customized Writer.

Hope it helps:).

-Yan

-----Original Message-----
From: rlipi [mailto:rlipi@(protected)]
Sent: May 27, 2004 03:20
To: 'Tomcat Users List'
Subject: RE: Can I change Tomcat's default character encoding?


Thank you for the answer.

I know about this possibility using filters (and I have done something).


But the original question (and my question) is about simpler way: Is it
possible to globally set (somewhere in JVM or Tomcat configuration)
default character encoding for all created Writers?

Lipi


> -----Original Message-----
> From: Yansheng Lin [mailto:yansheng.lin@(protected)]
> Sent: Wednesday, May 26, 2004 7:45 PM
> To: 'Tomcat Users List'
> Subject: RE: Can I change Tomcat's default character encoding?
>
> Hi, quick response, you can use your own customized
OutputStreamWriter.
> You
> need to extend the abstract class ServletOutputStream. And you
integrate
> your customized writer with tomcat by implementing a filter.
>
> For more info on how to use filters, you can do a search on google.
>
> This will only work for Tomcat 4 and up, or any other container that
> implement Servlet 2.3 and up.
>
> -Yan
>




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.