Bug 7424 - ResourceBundle lookup algorithm is not working as spec'd.
Summary: ResourceBundle lookup algorithm is not working as spec'd.
Status: CLOSED DUPLICATE of bug 7423
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Standard Taglib (show other bugs)
Version: unspecified
Hardware: All All
: P3 major (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-25 04:03 UTC by Ryan Lubke
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Lubke 2002-03-25 04:03:43 UTC
After tracing through BundleSupport and LocaleSupport classes of
org/apache/taglibs/standard/tag/core/fmt, I discovered that the preferred
locales as provided by the Accept-Language request header were being ignored.

The problem is that the algorithm will check to see if the context init param,
or scoped attribute javax.servlet.jsp.jstl.fmt.locale was set before
interrogating the browser locales.  This is correct based on the spec, however,
the problem lies in LocaleSupport.parseLocale(String, String) - line 170.  If a
null value was returned, as it would be of javax.servlet.jsp.jstl.fmt.locale was
not set, parseLocale(String, String) will return the default locale of the
system where the container runs, and thus return a value when none should be
returned (See line 221 of BundleSupport).  Based on the spec (Section 8.3.2,
page 8-73), I would think that consideration of the containers default locale
would be illegal.

I changed the null check in LocalSupport.parseLocale(String, String) to return
null instead of the default locale (see diff below) and the algorithm began to
work as expected.  I haven't spent the time to see if the diff below has any
side effects, but I believe this is enough information to correct the issue.

*****************************************************************
Index: LocaleSupport.java
===================================================================
RCS file:
/home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/LocaleSupport.java,v
retrieving revision 1.14
diff -u -r1.14 LocaleSupport.java
--- LocaleSupport.java	23 Mar 2002 01:33:50 -0000	1.14
+++ LocaleSupport.java	25 Mar 2002 03:55:29 -0000
@@ -175,7 +175,8 @@
 	int index = -1;
 
 	if ((locale == null) || locale.equals("")) {
-
    return Locale.getDefault();
+
    //return Locale.getDefault();
+        return null;
 	}
 
 	if (((index = locale.indexOf(HYPHEN)) > -1)
*************************************************************
Comment 1 Ryan Lubke 2002-03-25 04:11:55 UTC

*** This bug has been marked as a duplicate of 7423 ***