File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Internationalization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Internationalization" Watch "Internationalization" New topic
Author

Internationalization

Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Hi All,
Looking for some "best Practices" advice here. I have a properties file which I have some text messages defined in, for example, I have a String called "Select One" which I put as the first entry of several select box's. My question is this, right now, everytime I load the list of items for the select list, I open the properties file to get the value of the first item string "Select One" . Is this wrong to go fetch it every time, should I just fetch the string from the properties file once and store it in memory along with other similar strings I need for the application? I know how to load the property file and get the string values I need, just not sure if I should be only doing this once when the app starts up and storing the strings in an object, or just fetching them again and again as they are needed.
Thanks much for any opinions,
Kim
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

You should investigate the fmt class of tags from the JSTL and use a standardized approach.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Could I bother you to give me your opinion of the best way to do this without JSTL ? Thank you for taking the time to reply.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

You asked for best practices; that means the JSTL. Why are you reluctant to use it?
Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Just the usual, short on time, and I know how to get strings from a properties file, which seems like the way many people handle this situation. I wasn't really looking for a differant way to handle internationalization, I was more looking for a best practices on how to handle string values from a properties file, either :

Get them once and store in memory

or

Get them as I need them each time the jsp page is requested.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

Originally posted by Kim Kantola:
which seems like the way many people handle this situation.


Again, you asked for best practices, not what most people hack into their code.

If you are not going to use best practices, then I'd recommend that you at least use the properties and property bundle handling classes from the java.util package and let it handle any caching.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Internationalization
 
Similar Threads
Criteria setProjection result set
Hibernate: multiple subclasses not using fetchmode join
Using Properties instead of HashMap when dealing with Strings
JComboBox filterable with matching items
Best strategy to write Controller Servlet ?