Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Struts and the fly likes Accessing  Message Resource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Accessing  Message Resource" Watch "Accessing  Message Resource" New topic

Accessing Message Resource

Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240

I am looking for a way to access a message property that is maintained in the file in a Java class that is external to the Struts API.

I would like in a Java Class to be be able to say,

messageResource.get(key, locale) and get back the struts resource for the specified key.

Thanks in advance for any suggestions.

Never be satisfied with anything less than the best and you will surely pass the test...
Durgaprasad Guduguntla
Ranch Hand

Joined: Oct 20, 2003
Posts: 99
You can do this outside struts API by using a ResourceBundle assuming your bundle is located at yourapp/WEB-INF/classes/resources/ Then you an retrieve the messages from the bundle. The following code snippet would help you:

Thanks,<br />Durgaprasad<br />SCJP1.4, SCWCD1.4, SCBCD1.3,<br />SCEA
Durgaprasad Guduguntla
Ranch Hand

Joined: Oct 20, 2003
Posts: 99
One correction in the above post with code:
I agree. Here's the link:
subject: Accessing Message Resource
jQuery in Action, 3rd edition