From within a class loaded by the Webapp class loader you can call
InputStream is = this.getClass().getClassLoader().getResourceAsStream( "myProps.properties" ); Properties p = new Properties(); p.load( is ); Or from within an action/jsp you can do InputStream is = request.getSession().getServletContext().getResourceAsStream( "myProps.properties" ); Properties p = new Properties(); p.load( is ); You can place the .properties file within your WEB-INF/classes or WEB-INF/lib directory [EMAIL PROTECTED] wrote:
Hi! I would like my web-app to read in a *.properties file at startup (not for i18n, but the good old java.util.Properties, for example to get the e-mail address of the admin of the web-app). So I wrote a ServletContextListener which will load the properties-file and store it into servlet context from where it can be accessed throughout my web-app. But where I do have to put the myProps.properties file? I tried WEB-INF/classes, but I get a FileNotFoundException. Or do I have to configure web.xml or struts-config.xml in some way? Or is there a better way to store the required data (such as admin's e-mail)? Thanks Peter --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Gareth Evans MSoft eSolutions Limited Technology Centre Inward Way Rossmore Business Park Ellesmere Port Cheshire CH65 3EN -- Tel: +44 (0)870 0100 704 Fax: +44 (0)870 9010 705 E-Mail: [EMAIL PROTECTED] Web: www.msoft.co.uk ---------------------------------------------- Terms: Please note that any prices quoted within this e-mail are subject to VAT. All program details and code described in this e-mail are subject to copyright © of MSoft eSolutions Limited and remain the intellectual property of MSoft eSolutions Limited. Any proposal or pricing information contained within this e-mail are subject to MSoft eSolutions' Terms and Conditions ---------------------------------------------- Disclaimer: This message is intended only for use of the addressee. If this message was sent to you in error, please notify the sender and delete this message. MSoft eSolutions Limited cannot accept responsibility for viruses, so please scan attachments. Views expressed in this message do not necessarily reflect those of MSoft eSolutions Limited who will not necessarily be bound by its contents. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]