JSTL Displaying incorrect Locale
843838Nov 8 2006 — edited Nov 9 2006I'm seeing a very strange problem. Here's what I know. I am using Struts 1.2.9 & JSTL. I have a Filter that filters all requests and sets the Struts and JSTL Locale session variables using this pseudocode:
If there is a "locale" request parameter, create a new Locale with that value and use that, otherwise
If there is a Locale in the Globals.LOCALE_KEY Session attribute use that, otherwise
Get the Locale using the request.getLocale() and use that
If a Locale was found, set the Globals.LOCALE_KEY Session attribute and call Config.set(ses,Config.FMT_LOCALE,locale);
I have a bunch of debug logging in there and everything appears to be working correctly.
I have also created a Custom Tag that dumps a bunch of "useful" information to the logs including both of the Session attributes above. They are now showing up as:
[15:41:54.118] LogConfigSettingsTag.doStartTag: JSTL Configuration Settings
[15:41:54.118] LogConfigSettingsTag.doStartTag: * javax.servlet.jsp.jstl.fmt.locale: en_US
[15:41:54.118] LogConfigSettingsTag.doStartTag: * javax.servlet.jsp.jstl.fmt.localizationContext:
[15:41:54.134] LogConfigSettingsTag.doStartTag: Struts Configuration Settings
[15:41:54.134] LogConfigSettingsTag.doStartTag: * org.apache.struts.action.LOCALE: en_US (3)
[15:41:54.134] LogConfigSettingsTag.doStartTag: Session Attributes
[15:41:54.134] LogConfigSettingsTag.doStartTag: * org.apache.struts.action.LOCALE: en_US
[15:41:54.134] LogConfigSettingsTag.doStartTag: * javax.servlet.jsp.jstl.fmt.locale: en_US
So everything looks correct, but if my Accept-Language header is en-us,en;q=0.8,fr-ca;q=0.5,fr;q=0.3 the JSTL fmt:message tag chooses the French resources over the English. If the Accept-Language header is en-us,en;q=0.5 the JSTL fmt:message tag correctly uses the English resources. And no matter which Accept-Language header is sent, Struts bean:message uses the right resources.
If anyone has any idea what could be causing JSTL to use the wrong resource file, I'd really appreciate a pointer. I've been banging my head on this one for days.
(*Chris*)