wood burning stoves 2.0*
The moose likes Struts and the fly likes How to access a (non default) resource bundle from .jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to access a (non default) resource bundle from .jsp" Watch "How to access a (non default) resource bundle from .jsp" New topic
Author

How to access a (non default) resource bundle from .jsp

Norman Rozental
Greenhorn

Joined: Dec 24, 2003
Posts: 6
Hi there folks,
I've got in my .jsp:
In my struts-config-moduleName.xml file I've defined:

I'm getting the error:

I posted an earlier message asking how to obtain this bundle from within the Action class and had a reply which showed how to do this. But now I'm stuck with the .jsp way of accessing a bundle.
Any help would be most appreciated!
Happy new year!
Norman
Norman Rozental
Greenhorn

Joined: Dec 24, 2003
Posts: 6
I think I found the way to do it...
In my Action, I do:

I then include it as an belonging to the
Eg,
Then in my .jsp I've got:

And that's it. It works ok. Is this the proper way of doing things?
Cheers.
Norman.
Rick Hightower
Author
Ranch Hand

Joined: Feb 20, 2002
Posts: 350
You should not have to do that. Do this instead.

[ December 30, 2003: Message edited by: Rick Hightower ]

Rick Hightower is CTO of Mammatus which focuses on Cloud Computing, EC2, etc. Rick is invovled in Java CDI and Java EE as well. linkedin,twitter,blog
Norman Rozental
Greenhorn

Joined: Dec 24, 2003
Posts: 6
Hi Rick,
I tried what you suggested and get the error:

where xxx is the key defined as a message-resource in my struts-config-module.xml file.
I am using request scope. Would this cause a problem? Maybe what you suggest can only be applied to the default struts-config.xml file?
Confused.
Normie.
Benson Fung
Ranch Hand

Joined: Apr 10, 2003
Posts: 207
Norman,

I got the same as you have right now. It seems it doesn't work in struts-config-moduleName.xml file.

Do you have alternatives? Becasue I don't want to use programming to config the resources bundle.


Thanks
Benson
Hao Zhang
Greenhorn

Joined: May 10, 2004
Posts: 4
Same problem, I think it must be a bug of struts 1.1,
but I found JSPs in module can get the default resources, so I define common messages in struts-config.xml like this:

then in JSP use:

to retrive "mykey" message. besides, <bean:write> tag without bundle property specified can get module messages as well.
BTW, the validator plugin's standard messages can not be found anyway.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to access a (non default) resource bundle from .jsp
 
Similar Threads
can we use struts tag in spring frame work?
Using resource bundle as input for a custom tag
message resource bundles question
Spring Message Reources - Struts tags
Getting values from properties in validate-using multiple message-resources in struts