tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tõnu Põld <>
Subject RE: Character Encoding Problem
Date Mon, 02 Jul 2001 14:26:04 GMT

I still believe your initial bytes are converted to java strings (unicode)
using a wrong encoding.

If you have a string created from bytes using the "ISO-8859-9" encoding, and
if the JSP page has a directive <%@ page content-type="ISO-8859-9"%>, then
it should be OK. 

For debuging you could try to convert your string to another encoding, look
what happens.
For example:

<%@ page content-type="ISO-8859-9"%>
String s = new String( initalString.getBytes("ISO-8859-1"), "ISO-8859-9");
<%= s %>

If this dislays your string correctly, then you have used the "ISO-8859-1"
encoding in creation of a java string from inital bytes!

By the way which version of Tomcat are you using. An older release (3.2.1)
had some bugs with encoding conversion. Try the latest 3.2.2 release.

The request parameters from HTTP post are probably in "ISO-8859-1" encoding
because most browsers do not specify the encoding when submiting a request,
so Tomcat uses the default encoding. To convert them correctly to java
strings encoding, the following could be used (assuming that they really are
String param = new String( initalParam.getBytes("ISO-8859-1"),


> -----Original Message-----
> From: []
> Sent: Monday, July 02, 2001 3:34 PM
> To:
> Subject: RE: Character Encoding Problem
> > > When reading bytes from file with FileReader the default 
> character encoding
> > > is used.
> > > I think you must specify your own encoding when reading the file.
> > >
> > 
> > I'll try that. But the same compiled classes and the same 
> jdk version works well with Resin JSP Server and the files. 
> The problem occurs with Tomcat.
> > 
> Nay, still problems. A lot of ?'s in the visual output. 
> Himpf. The point is, which is interesting, if a have an html 
> form with ISO-8859-9 encoded chars, and post it to a jsp 
> file, and write the parameters to a system text file, the 
> text is correct!!
> The problem seems to occur during displaying strings obtained 
> from inside a class .. Any other display problems with other 
> character sets ?? .. Any more idea ?? ..
> Let's remember the problem. We cannot display ISO-8859-9 
> encoded string constants of a class, or strings read from a 
> file, in jsp documents in correct encoding.
> Usage of <%@ page content-type does not solve
> Usage of javac -encoding does not solve
> Usage of encodings in file read/writes of routines 
> does not solve
> The problem is with Tomcat, no problems with Resin used in 
> the same environment, OS/JDK.
> Arif ..

View raw message