Return-Path: Delivered-To: apmail-jakarta-taglibs-dev-archive@jakarta.apache.org Received: (qmail 8007 invoked by uid 500); 22 Aug 2001 08:30:29 -0000 Mailing-List: contact taglibs-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: taglibs-dev@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list taglibs-dev@jakarta.apache.org Received: (qmail 8000 invoked from network); 22 Aug 2001 08:30:28 -0000 Received: from brainwasher.iway.fr (212.208.127.1) by h31.sny.collab.net with SMTP; 22 Aug 2001 08:30:28 -0000 Received: from cartman ([213.11.10.91]) by brainwasher.iway.fr (8.9.3/8.8.7) with SMTP id KAA41904175 for ; Wed, 22 Aug 2001 10:27:46 +0200 (METDST) Content-Type: text/plain; charset="iso-8859-1" From: Fred To: taglibs-dev@jakarta.apache.org Subject: Fwd: i18n LocaleTag & FormatDateTimeTag: problem getting the right locale. Date: Wed, 22 Aug 2001 10:29:38 +0200 X-Mailer: KMail [version 1.2] MIME-Version: 1.0 Message-Id: <01082210293807.01385@cartman> Content-Transfer-Encoding: 8bit X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Cross-posted on the User mailing list. ------------------------------------------------------- Hi, I'm currently changing my date tag to use the i18n ones but there seem to be a problem in the LocaleTag class. If the locale is not given has a parameter the LocaleTag & FormatDateTimeTag use the LocaleTag.getLocale( pageContext ) method to retreive the correct locale. The problem is that this method check first the response locale. It's a good idea if we want to reply in another language but in the servlet API from Sun we can found that the response.getLocale() return the server locale by default. ("By default, the response locale is the default locale for the server." in setLocale() description at http://java.sun.com/products/servlet/2.2/javadoc/index.html ) So this method ALWAYS return something not null ! I have the latest release (today 21/08/2001). Is this a misunderstand of the usage of the tag libray from myself, or a problem from my web server (Tomcat 3.2.3) or is this a mistake in the i18n tag library ? Thanks in advance. Fred. Copy of the getLocale() Method from LocaleTag : /** Extracts the {@link Locale} from the given {@link ServletRequest} * or returns the default JVM's {@link Locale} if it could not be found */ protected static Locale getLocale( PageContext pageContext ) { Locale answer = pageContext.getResponse().getLocale(); if ( answer == null ) { ServletRequest request = pageContext.getRequest(); answer = request.getLocale(); if ( answer == null ) { for ( Enumeration enum = request.getLocales(); enum.hasMoreElements(); ) { answer = (Locale) enum.nextElement(); if ( answer != null ) { break; } } if ( answer == null ) { // XXXX: may wish to log warning? answer = Locale.getDefault(); } } } return answer; } -------------------------------------------------------