🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #1672

Can't set servlet language output to Japanese!?

#1672
From: Alex Colic
Date: Sun, 28 Oct 2001 22:59
51 lines
2607 bytes
Hi,

I have not been able to set my servlets output language to Japanese. I have
created two files application.properties and application_ja.properties. My
code to set the language is found below. When I set my browsers (IE 5.5)
language to Japanese, I can see that the Locale created below is 'ja' and
that the charset is set to 'Shift_JIS' but the web page outputed is:

In Japanese:
Hello World Default

The problem is that the greeting "Hello World Default" if found in my
default application.properties file.

In application_ja.properties I have the following:
greeting=\u4eca\u65e5\u306f\uu4e16\u754c

Can someone help me out.

Thanks in advance.

Alex

    try
      {
        String bundleName="application";
        String acceptLanguage=request.getHeader("Accept-Language");
        String acceptCharset=request.getHeader("Accept-Charset");
        LocaleNegotiator negotiator =new LocaleNegotiator(bundleName,
acceptLanguage, acceptCharset);

        Locale locale=negotiator.getLocale();
        String charset=negotiator.getCharset();
        ResourceBundle bundle=negotiator.getBundle();

        response.setContentType("text/plain; charset=" + charset);
        response.setHeader("Content-Language", locale.getLanguage());
        response.setHeader("Vary", "Accept-Language");

        PrintWriter out = response.getWriter();

        if(bundle !=null)
                  {
                    out.println("In " + locale.getDisplayLanguage() + ":");
                    out.println(bundle.getString("greeting"));
                  }
                else
                  {
                    out.println("Bundle could not be found");
                  }
      }
Technical Details
Message-ID: <3bdc8dc2$1_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!supernews.com!telocity-west!TELOCITY!nntpserver.com!hub1.nntpserver.com!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!dnews

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,3d0896b593c3290,start
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2001-10-28 15:10:00 PST
From: "Alex Colic" <alex.colic@pop-ware.com>
Newsgroups: borland.public.jbuilder.java.api
Subject: Can't set servlet language output to Japanese!?
Date: Sun, 28 Oct 2001 17:59:08 -0500
Lines: 53
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
NNTP-Posting-Host: 24.150.29.218
Message-ID: <3bdc8dc2$1_2@dnews>
X-Trace: dnews 1004309954 24.150.29.218 (28 Oct 2001 14:59:14 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!supernews.com!telocity-west!TELOCITY!nntpserver.com!hub1.nntpserver.com!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!dnews