tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Smith <d...@cornell.edu>
Subject Re: jndi.properties
Date Wed, 03 May 2006 13:40:52 GMT
Or better yet, use ServletContext#getResourceAsStream() as follows:

Properties jndiProps = new Properties() ;
try {
  jndiProps.load( getServletContext().getResourceAsStream(
"/any/webapp/relative/folder/jndi.properties" ) ) ;
} catch ( IOException ioe ) {
  // Log and handle error
}

This works whether the file is in a war or a webapp folder.  The code
above assumes you are executing from a servlet or jsp.

--David

abdurrahman sahin wrote:

>i never tried it with default ctor, used it as 
>new InitialContext(jndiProperties);
>using DirectoryFinding methods may help you like below.
>String realPath = request.getRealPath(request.getContextPath());
>That should return the path up to where you have your servlet context. 
>
>
>
>-----Original Message-----
>From: Feris Thia [mailto:feris.tia@gmail.com]
>Sent: Wednesday, May 03, 2006 3:56 PM
>To: Tomcat Users List; abdurrahman.sahin@argela.com.tr
>Subject: Re: jndi.properties
>
>
>Ic.... so we cannot just load it from the directory where jsp are and
>use this code ?
>
>=====================================
>InitialContext jndiContext = new InitialContext();
>=====================================
>
>On 5/3/06, abdurrahman sahin <abdurrahman.sahin@argela.com.tr> wrote:
>  
>
>>i think , it is actully related to where you are looking for.
>>i think you can put it anyware as long as the diretory you put it is
>>accessible.
>>
>>http://asahin.net
>>
>>private static final String CONFIG_FILE="resources/jndi.properties";
>>FileInputStream fis = new FileInputStream(CONFIG_FILE);
>>                        myProperties.load(fis);
>>
>>
>>    
>>
>
>
>--
>Regards,
>Feris
>PT. Putera Handal Indotama
>JL. KH. Moh. Mansyur No. 11 Blok B.8-12
>Telp. +62-21-631 6688 (Hunting)
>Fax. +62-21-6330211
>Jakarta (10140) - INDONESIA
>
>---------------------------------------------------------------------
>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
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message