I have a strange problem, where localization is working great, except on our error pages.
I am using the Stripes framework, resource bundles and the JSTL tag to localize my pages. The locale is determined by the Stripes framework. According to the Stripes documentation:
Stripes uses a HttpServletRequestWrapper to makes calls to request.getLocale() and request.getLocales() return only the chosen locale. This means that not only Stripes will use the correct locale without having to re-determine it, but that any other localization tool that relies on request.getLocales should also default to the correct locale. This includes the JSTL fmt:* tags - cool huh?
This works great everywhere except when a 404 or 500 error happens, which directs to our error page, which is configured like this in web.xml:
<error-page>
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page>
If I browse directly to the error page, localization works fine. For example, if I've already set the language to Spanish, then browse to this url, the page appears in Spanish:
http://localhost:8080/error.jsp
But if I set the language to Spanish and then browse to:
http://localhost:8080/this-page-does-not-exist-create-a-404-error
The same error page appears, but rendered in English.
Why is that, and how do I fix it? I've searched all over with no results!
I should add, I have tried checking request.getLocale() manually, and it is set to en_US.
In the code that sets the Locale, we also set some session attributes, "lang" and "country".
As a work around, I've found I can read these attributes and reconstruct the locale, but I would like to know why this is happening in the first place.