I\'m trying to iterate through a set of keys in a properties file, so that only the \"message.pX\" is output.
a.property=foo
message.p1=a
message.p2=b
message.p3
Properties properties = new Properties();
try {
properties.load(new FileInputStream("filename.properties"));
} catch (IOException e) {
}
Enumeration e = properties.propertyNames();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
//Edited answer
if(key.indexOf("message.p") != -1 ){
System.out.println(key + " , " + properties.getProperty(key));
//Add key and value to a list
}
//Edited answer
}
I suggest you to do this inside a Servlet or a Java class and store the properties list in a java.lang.List object such as an ArrayList or LinkedList then send the result to the jsp. Avoid doing this inside the jsp.