This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
since your requirement seems to be only to support a large set of data I guess it would be
easier to put in to a properties file. What I am thinking is that coding all of these values will
be very tedious. However there may be many ways how this can be accomplished.
Also if these values need to be changed from time to time properties file could be the way to go.
If these values should not be changed easily, putting in a property file may not be good.
Joined: Nov 28, 2011
no, i do not need to change these values. the values remain static. Any other way to go? I am processing this data while navigating between two jsp pages.
If you have a set of key-value pairs then HashMap is the obvious thing to use. If those pairs have to come from an external file where they live permanently, then Properties would be the thing to use, but it sounds like that isn't the case. So use HashMap.
If you use Properties then readers of your code are going to assume that your data comes from an external file, because that's what Properties is for. So if your data doesn't come from an external file, then don't use Properties or you are going to confuse people.
Joined: Nov 28, 2011
This is my situation- I am navigating between to jsps, and i am calling a method there by a class in between. This method uses a fixed set of key-value pairs. So every time i should initialize this hash map, just like another variable. So this wouldn't be an overhead? as the set of values is a bit large. How does the property file works? It is also loaded each time?
If the values won't change, loading them for each individual request is rather ridiculous. Employ a context listener to create the map once at startup, and store it in the application context where it can be accessed by all web app resources.
Whether you load it from a properties file or in code is rather moot. Choose which approach makes the most sense for code clarity.