tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject How to create a general resource bundle for JSTL?
Date Fri, 04 Jul 2003 16:08:20 GMT
Hi all

Till now, all JSP pages in our application had to have the following header
for internationalization:
<%@ taglib prefix="fmt" uri="" %>
<fmt:setLocale value="${currentLocale}"/>
<fmt:setBundle basename="ch.xobix.i18n.translations.X2Resources"
var="bundle" scope="page"/>

Then a message would be output like this:
<fmt:message key="longWeekday_0" bundle="${bundle}"/>

Note that "currentLocale" is set by the controller, and
ch.xobix...X2Resources is a class that loads the messages from a database
This works well, however I think it's tedious for the web designer to do
this manually all the time.

My goal is to have the following:
<%@ taglib prefix="fmt" uri="" %>

And the message output like this:
<fmt:message key="longWeekday_0"/>

So I tried to set it in the controller, as described in "JSTL in Action". I
managed to set the Locale right, but I don't know how to do the same with
the resources. First I tried according to the book to create a
ResourceBundle and a Locale and set JSTL's FMT_LOCALIZATIONCONTEXT (does
anyone know why this is written like this?). Didn't work...

Now I've seen that I can change the web.xml to read

Now, in the controller, I set the Locale with
Config.set(this.getRequest(), Config.FMT_LOCALE, <the language code> );

and I see it in Tomcat's output:
DEBUG  - Request: javax.servlet.jsp.jstl.fmt.locale = it   (when changing to

BUT the message itself doesn't change!

What am I doing wrong? Or how should I do it right?

Also, has anyone of you succeeded in dynamically changing resources? Right
now, when someone enters a new key in the database, we have to restart

Thanks for any help!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message