Nikola Stefanovski wrote:

> hello.
> 
> i'm working with cyrillic characters and i can't get them to show ok.
> i'm working on win2000 and i've tried tomcat versions 3.2.3, 3.3a and 4.0.1.
> the page directive is specified as:
> 
> <%@ page contentType="text/html; charset=windows-1251"
> pageEncoding="windows-1251"%>
> 
> this makes the static content of the jsp appear correctly, but the strings
> retrieved  through an expression (<%=bean.getString()%>) are just
> question-marks. if i take out the page attribute, the browser shows some
> funny characters as it doesn't recognise the encoding. but if i then switch
> to cyrillic (windows) encoding manually, everything appears fine.
> i can't figure out where the catch is, any help?

Sounds like you got something wrong in the database part of your web 
application. From what you've said, I can only conclude that what your 
JSP/Servlet reads is a totally incorrect string.

Java supports only UNICODE, as it's internal character encoding. So, if you have 
an architecture like this:

RDBMS <-> JDBC <-> JRE <-> Tomcat <-> Servlet(JSP) <-> HTTP

then JDBC must read characters INTO the Unicode encoding. ServletResponse class 
will translate Unicode into specified HTTP encoding. Given your description of 
the problem, I'd say you have CP-1251 encoded text that gets just pasted into 
Unicode. This is irregular, since CP-1251 is not getting translated into proper 
Unicode characters. I'd say you have wrong setup of your DB.

I've had similar problems with PostgreSQL and Tomcat, my data was CP-1250 and I 
was forcing it as Unicode. My problems went away when I translated CP-1250 into 
Unicode on the DB side and set DB encoding to UTF-8. I believe things would be 
OK if I switched to any other supported encoding of the DB.

I'd say you have the same problem as I did - DB was of one encoding and data of 
the other.

Nix.

P.S. I'm on a vacation for the next ten days, so I won't be answering my mails.


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to