Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 40192 invoked from network); 26 May 2009 21:34:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 May 2009 21:34:31 -0000 Received: (qmail 21794 invoked by uid 500); 26 May 2009 21:34:40 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 21751 invoked by uid 500); 26 May 2009 21:34:40 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 21740 invoked by uid 99); 26 May 2009 21:34:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 May 2009 21:34:40 +0000 X-ASF-Spam-Status: No, hits=-2.8 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: 128.253.83.141 is neither permitted nor denied by domain of dns4@cornell.edu) Received: from [128.253.83.141] (HELO authusersmtp.mail.cornell.edu) (128.253.83.141) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 May 2009 21:34:31 +0000 Received: from [192.168.5.101] (cpe-67-244-39-127.twcny.res.rr.com [67.244.39.127]) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.13.1/8.12.10) with ESMTP id n4QLY9JO018532 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 26 May 2009 17:34:10 -0400 (EDT) Message-ID: <4A1C6053.1000808@cornell.edu> Date: Tue, 26 May 2009 17:34:11 -0400 From: David Smith User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Problem Reading Property files References: <46dc841e0905260726w4a1f4411m6d465a49ba8a05e0@mail.gmail.com> <4A1C2660.8070804@iki.fi> <46dc841e0905261107v3246f5ecs967ea3eeef77002a@mail.gmail.com> <4A1C3645.4080107@iki.fi> <46dc841e0905261148p73587b1i5c717642fb432538@mail.gmail.com> In-Reply-To: <46dc841e0905261148p73587b1i5c717642fb432538@mail.gmail.com> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Assuming you wrote this servlet, it would *really* help if you provided relevant parts of your servlet where this file is read. We're flying blind here. Normally the servlet would do something like this: class MyServlet extends javax.servlet.http.HttpServlet { function init(ServletConfig sc) throws javax.servlet.ServletException { string properties_file_path = sc.getInitParameter( "loan.props" ) ; try { loanProps = new java.util.Properties() ; loanProps.load( sc.getServletContext().getResourceAsStream(properties_file_path) ) ; /* Do something with the properties object ... maybe make it a class variable. */ } catch (java.io.FileNotFoundException fnfe) { throw new ServletException( "Could not configure. Servlet disabled.", fnfe) ; } } /* other methods here */ } This may not be perfect, but it's enough to illustrate the idea. With the above, you should be able to declare the path to your properties in the web.xml as servlet init-params. I'm guessing iPlanet is doing something different. What's posted above is supported as part of the servlet spec. --David john S wrote: > I placed under WEB-INF itself. I created a directory called config adn > placed the abc.props and abc.log under it. > > Whether i need to configure them in the web.xml? or should i remove it from > there. > > Because wen i removed the init param, there is no change i am getting the > same error......not able to find the abc.props or abc.log files > .........FILENOTFOUNDEXCEPTION. > > Just want to know where should i specify them. > > On Tue, May 26, 2009 at 2:34 PM, Juha Laiho wrote: > > >> john S wrote: >> >>> Actually, I am not sure where to place and configure the property >>> files (*SERVLET ARGS*) in tomcat. >>> >> If it's ok for you to have the files deployed along with your application, >> then I'd like to propose the following: >> Place the files within /WEB-INF/ directory in your web application. >> You could also create a subdirectory within /WEB-INF/ to contain >> just these files, such as /WEB-INF/config/ . >> >> Then read the files with getResourceAsStream method of ServletContext, >> and process the stream to get the data you need. This way is specified >> by the Servlet specification, so is portable across different containers. >> >> >> Files places within /WEB-INF/ cannot be accessed by direct browser >> requests, so they are safe from prying eyes. >> >> The other way would be to place the configuration files outside >> your web application. For this you'll likely want to split the >> "root" directory for the files from the file names (and possibly >> directory hierarchy underneath the "root") so that the placement >> underneath the "root" is dictated by the application, but the "root" >> location is set from outside the application. For this there is no >> standard way, but you could use a Java system property (specified >> with "-Dprop_name=value" on the JVM command line), or Tomcat context >> parameters, to set the root directory. The placement underneath the >> root would still be as it is now. Then in your code you'd concatenate >> the "root" location with the file path/name from web.xml and process >> the files as such. >> >> -- >> ..Juha >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org >> For additional commands, e-mail: users-help@tomcat.apache.org >> >> >> > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org