tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Manger, James H" <>
Subject Tomcat: using an extra CharsetProvider in a servlet
Date Fri, 11 Oct 2002 07:41:41 GMT
I would like to use a non-standard character set for selected operations
within a servlet.  I have implemented a CharsetProvider, Charset,
CharsetEncoder & CharsetDecoder.

I can use my new character set from a Java application by listing the
CharsetProvider class name in the following file within the application JAR.
(see API for CharsetProvider)

My application (without any particular "import" statements) can make calls
such as:
	String msg = "Hello, World!";
	byte[] encoding = msg.getBytes("MY-CHARSET");

I cannot get these lines to work in a servlet -- the
msg.getBytes("MY-CHARSET") throws:
	java.nio.charset.UnsupportedCharsetException: MY-CHARSET

QUESTION: How do I tell the system running my servlet about my character

Adding a JAR with the character set (and META-INF... file) to the jre/ext/
directory makes the character set available to all Java apps - but not to
the servlet!  Adding the JAR to tomcat/common/lib/ did not seem to work

My servlet can see my CharsetProvider class, but my CharsetProvider is not
"registered" with the system (and it needs to be "registered" for
String.getBytes("MY-CHARSET") to work).

[JWSDP 1.0_01, J2SE 1.4.0_01, Tomcat 4.1.2, SunOS 5.6]

James Manger

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message