Suppose you have

<% String countryCode = "en"; %>

I think <bean:message key="yourPropertyKey" bundle="<%=countryCode%>"> will do your 
work.

Another way is that you save your Locale object to session in jsp something like

session.setAttribute(Globals.LOCALE_KEY, yourLocaleObject); 

then Struts can just find out the correct resource for different locale
when you use the following in the jsp
<bean:message key="yourPropertyKey">

Hope this helps.

Larry Zhang


-----Original Message-----
From: None None [mailto:[EMAIL PROTECTED]
Sent: Friday, May 14, 2004 11:40 AM
To: [EMAIL PROTECTED]
Subject: How to access a variable message resource bundle from JSP


Hi again everyone... yesterday, with assistance from some of you folks, I 
was able to get multiple message resource bundles working to return a 
Locale-specific error message from one of my Action classes.  Very cool.

Now I'm trying to do the same thing in a JSP.

Here's my question... in my JSP's, when using <bean:message>, I know that I 
can specify bundle="en" or bundle="de" and that works, since I have a 
properties file set up for English and German.  But how can I set the bundle 
attribute to a variable value?

In other words, at present I have String in session called countryCode, and 
it's literally the value EN, DE, or whatever else.  So, is there a way I can 
plug that string into the <bean:message> tag's bundle attribute?

Or, is there another method of specifying which of a number of message 
resource bundle to look in for a specific key that can be varied 
programmatically?  Or further still, is there specifically a special method 
to get locale-specific string in a JSP tag, as I am now able to do in my 
Action classes?

Thanks all!

_________________________________________________________________
MSN Toolbar provides one-click access to Hotmail from any Web page - FREE 
download! http://toolbar.msn.click-url.com/go/onm00200413ave/direct/01/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to