Bug 7423

Summary: ResourceBundle lookup algorithm is not working as spec'd.
Product: Taglibs Reporter: Ryan Lubke <Ryan.Lubke>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: CLOSED FIXED    
Severity: major    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: A more complete patch that handles the value attribute of fmt:locale being null or empty and allows the ResourceBundle lookup algorithm to work as spec'd.
Updated patches

Description Ryan Lubke 2002-03-25 03:59:54 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:56 UTC
*** Bug 7424 has been marked as a duplicate of this bug. ***
Comment 2 Ryan Lubke 2002-03-25 04:12:24 UTC
*** Bug 7425 has been marked as a duplicate of this bug. ***
Comment 3 Ryan Lubke 2002-03-25 04:12:46 UTC
*** Bug 7426 has been marked as a duplicate of this bug. ***
Comment 4 Ryan Lubke 2002-03-25 15:25:43 UTC
Going back over the spec, I see why the containers default locale is used,
however, there is still the issue of this providing the default locale when it
shouldn't be.

Comment 5 Ryan Lubke 2002-03-25 18:10:15 UTC
Created attachment 1421 [details]
A more complete patch that handles the value attribute of fmt:locale being null or empty and allows the ResourceBundle lookup algorithm to work as spec'd.
Comment 6 Ryan Lubke 2002-03-26 22:20:01 UTC
Created attachment 1429 [details]
Updated patches