You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ben Kelley <be...@ubsw.com> on 2001/07/16 09:09:53 UTC
Internationalisation problems in Tomcat 3.3?
Hi.
I've seen a couple of posts about problems with i18n and Tomcat. I am having
trouble with this, and at this point I'm suspecting a bug somewhere.
The same test servlet works fine with Apache JServ 1.0, but displays
"???????" in Tomcat 3.3m4.
Consider the test servlet below. If you call http://yourserver/servlet/test
you get just "English". if You call http://yourserver/servlet/test?lang=ja
it should display some Japanese (encoded as euc-jp).
The Japanese text uses the unicode escapes for the appropriate characters.
As I was writing this e-mail, I hit refresh on my site and the Japanese
version worked. I loaded up some English pages, and the Japanese version
went back to "??????".
If you uncomment out the resp.getCharacterEncoding() lines you should find
that you get the correct answer for each case.
Any thoughts?
- Ben Kelley.
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class test extends HttpServlet
{
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
{
try
{
if ((req.getParameter("lang") != null) &&
req.getParameter("lang").equals("ja"))
{
resp.setContentType("text/html; charset=euc-jp");
PrintWriter out = resp.getWriter();
out.println("<html><head><title>Japanese</title></head>");
out.println("<body>");
out.println("<p>Japanese</p>");
// out.println("<p>Encoding is " +
resp.getCharacterEncoding());
out.println("<p>Location = \u6240\u5728\u5730\uff1a</p>");
out.println("<p>Latest research updates =
\u76f4\u8fd1\u306e\u30ea\u30b5\u30fc\u30c1\u53ca\u3073\u66f4\u65b0</p>");
out.println("</body>");
out.println("</html>");
}
else
{
resp.setContentType("text/html; charset=iso-8859-1");
PrintWriter out = resp.getWriter();
out.println("<html><head><title>English</title></head>");
out.println("<body>");
out.println("<p>English</p>");
// out.println("<p>Encoding is " +
resp.getCharacterEncoding());
out.println("</body>");
out.println("</html>");
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Ben Kelley - ben_kelley@ubsw.com
Senior Web Developer - ResearchWeb
UBS Warburg, Sydney, Australia
Visit our website at http://www.ubswarburg.com
This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.
Re: Internationalisation problems in Tomcat 3.3?
Posted by Gregor Kovaè <gr...@mikropis.si>.
Hi!
I had the same problems using a database. I don't know if this applies to
your case, but nevertheless:
I created a database in Cp1250 or Latin2 encoding. Then I have put <%@page
contentType = "text/html; charset=windows-1250" %> on top of my JSP page
and things work now.
Best regards,
Kovi
P.S.: I have done this with MySQL, DB2 and Interbase.
At 17:09 16.7.01 +1000, you wrote:
>Hi.
>
>I've seen a couple of posts about problems with i18n and Tomcat. I am having
>trouble with this, and at this point I'm suspecting a bug somewhere.
>
>The same test servlet works fine with Apache JServ 1.0, but displays
>"???????" in Tomcat 3.3m4.
>
>Consider the test servlet below. If you call http://yourserver/servlet/test
>you get just "English". if You call http://yourserver/servlet/test?lang=ja
>it should display some Japanese (encoded as euc-jp).
>
>The Japanese text uses the unicode escapes for the appropriate characters.
>
>As I was writing this e-mail, I hit refresh on my site and the Japanese
>version worked. I loaded up some English pages, and the Japanese version
>went back to "??????".
>
>If you uncomment out the resp.getCharacterEncoding() lines you should find
>that you get the correct answer for each case.
>
>Any thoughts?
>
> - Ben Kelley.
>
>import javax.servlet.*;
>import javax.servlet.http.*;
>
>import java.io.*;
>
>public class test extends HttpServlet
>{
> protected void doGet(HttpServletRequest req, HttpServletResponse resp)
> {
> try
> {
> if ((req.getParameter("lang") != null) &&
>req.getParameter("lang").equals("ja"))
> {
> resp.setContentType("text/html; charset=euc-jp");
> PrintWriter out = resp.getWriter();
> out.println("<html><head><title>Japanese</title></head>");
> out.println("<body>");
> out.println("<p>Japanese</p>");
> // out.println("<p>Encoding is " +
>resp.getCharacterEncoding());
>
> out.println("<p>Location = \u6240\u5728\u5730\uff1a</p>");
> out.println("<p>Latest research updates =
>\u76f4\u8fd1\u306e\u30ea\u30b5\u30fc\u30c1\u53ca\u3073\u66f4\u65b0</p>");
> out.println("</body>");
> out.println("</html>");
> }
> else
> {
> resp.setContentType("text/html; charset=iso-8859-1");
> PrintWriter out = resp.getWriter();
> out.println("<html><head><title>English</title></head>");
> out.println("<body>");
> out.println("<p>English</p>");
> // out.println("<p>Encoding is " +
>resp.getCharacterEncoding());
> out.println("</body>");
> out.println("</html>");
> }
> }
> catch (Exception e)
> {
> e.printStackTrace();
> }
> }
>}
>
>Ben Kelley - ben_kelley@ubsw.com
>Senior Web Developer - ResearchWeb
>UBS Warburg, Sydney, Australia
>
>
>Visit our website at http://www.ubswarburg.com
>
>This message contains confidential information and is intended only
>for the individual named. If you are not the named addressee you
>should not disseminate, distribute or copy this e-mail. Please
>notify the sender immediately by e-mail if you have received this
>e-mail by mistake and delete this e-mail from your system.
>
>E-mail transmission cannot be guaranteed to be secure or error-free
>as information could be intercepted, corrupted, lost, destroyed,
>arrive late or incomplete, or contain viruses. The sender therefore
>does not accept liability for any errors or omissions in the contents
>of this message which arise as a result of e-mail transmission. If
>verification is required please request a hard-copy version. This
>message is provided for informational purposes and should not be
>construed as a solicitation or offer to buy or sell any securities or
>related financial instruments.