Actually it doesn't matter whether it's a servlet or a jsp. A JSP is a servlet after all. Now granted this is way off topic, and I would be like wendy and do it in an action then put the properties (or some other collection of the key-value pairs) into the request and do it that way. With that said here is some code that will effectively do what you are asking for inside the JSP - based on Wendy's code as I'm too lazy to type the X extra lines :)
Note I have never gotten this to work when *.properties is in the base WEB-INF/classes... I never really put props there anyways so for me it would never be an issue. (I always put them in WEB-INF/classes/resources) <[EMAIL PROTECTED] contentType="text/html" %> <[EMAIL PROTECTED] import= "java.util.*, java.io.*" %> <table> <tr> <td>key</td> <td>Value</td> <tr> <% String propsFileName = "resources/messages.properties"; Properties props = new Properties(); ClassLoader cl = this.getClass().getClassLoader(); InputStream input = cl.getResourceAsStream( propsFileName ); props.load( input ); Enumeration e = props.keys(); while(e.hasMoreElements()) { String key = (String)e.nextElement(); String val = props.getProperty(key); %> <tr> <td><%= key %></td> <td><%= val %></td> </tr> <% } %> -----Original Message----- From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 30, 2005 4:29 PM To: Struts Users Mailing List Subject: Re: [OT] Re: Iterate through blah.properties file From: "Brian McGovern" <[EMAIL PROTECTED]> > Thanks. I figured I know I can get it to work in servlet code but im hoping to avoid that. > I know that single properties are made available by the framework in taglibs like this <bean:message > key="error.application_error" />. Ther has to be a simple way to just get ALL the properties in a particular > bundle directly from the jsp itself. Right? Sorry, I didn't pay attention to the "in my JSP" part. I'd probably just do what I already posted in an Action, and stick the Properties object in the request/session/application [as appropriate]. I haven't done it, but Properties extends from Hashtable, so JSTL should iterate over it with no problem. I do see an org.apache.struts.util.PropertyMessageResources object in Application scope under key org.apache.struts.action.MESSAGE. Is that where the data in ApplicationResources.properties ends up? I don't think you can get at its data-- there's a HashMap, but it's protected. http://struts.apache.org/api/org/apache/struts/util/MessageResources.htm l Maybe someone who knows more about the internal workings of Struts can comment; I'm guessing at this point. -- Wendy Smoak --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]