Skip to main content

Load Message Resources from Struts Action

Posted by ahashim on March 10, 2007 at 4:39 AM PST

Sometime, you will need to read some text from the resource files in your application from the Struts Action class. The easier way which most developers are using is to open the resource file using the java.util.ResourceBundle class, which will open the file and read its content.

PropertyResourceBundle properties=(PropertyResourceBundle)ResourceBundle.getBundle(propertyFileName);

This will open the file for every request to your action! I am sure that it is very bad from the performance point.

Struts provide a methods in the Action class to get the locale and the resources

getLocale(request) and getResources(request)

For some reason, getResources() didn

Related Topics >>