There is two different problems, first of all if you want to
receive russian characters in servlet output you
have to specify output encoding by res.setContentType("text/html;
charset=windows-1251");
it is important to specify encoding which is known to java (for 1251 it is
windows-1251 and Cp1251, case of letters is also important)
Second problem is input from html forms and this problem
has no simple decision. Some servlet engines work right if you specify
encoding by Content-Type header (for example Resin - www.caucho.com),
other always translate query from ISO-8859-1 to unicode (so
you receive question signs). You can parse query string
yourself or can transform ISO-8859-1 to Cp1251 like this:

String result = new String( parameter.getBytes("ISO-8859-1"), "Cp1251");

Now I am trying to write java package which can help with this problems,
but the work only began, so you have to wait.


Vyacheslav Pedak

----- Original Message -----
From: Gleb Koukhta <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, April 03, 2000 10:01 PM
Subject: [NES-MANAGERS] Troubles with the russian language in servlets


> Hello, everybody !
>
> I has changed text to russian in the sample servlet HelloWorldServlet,
> which one is coming with iPlanet webserver 4.1 ,recompiled and installed
> it. Instead of the russian text I'm getting only question signs in the
> Netscape Communicator. Problem is, that servlet's output depends on the
> HTTP ACCEPT-CHARSET sent from communicator in the HTTP GET request, but
> it is wrong for Russia(en,*,UTF-8) and can't be changed from GUI, only
> in the prefs.js file, what is confusing for users on Internet. If one
> will edit file prefs.js or connect from the Microsoft's Internet
> Explorer he will see a russian text.
> In the beginning of doGet I has set locale:
> Locale MyLocale=new Locale("ru","RU");
> res.setLocale(MyLocale);
> file://Then I has set content type:
> res.setContentType("text/html; charset=Windows-1251");
> file://After all I'm calling getWriter:
> PrintWriter out = res.getWriter();
>
> It doesn't work - I can see only question marks on the servlet output
> page. The same problems with the russian characters sent to servlets
> from HTML forms - all russian characters replaced with question signs.
> May somebody know how to solve these problems ?
>
> Gleb.
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to