| Author |
Reading file from tomcat, outside servelet.
|
Ranban Smith
Greenhorn
Joined: Aug 18, 2011
Posts: 2
|
|
Hi,
I am working on a tomcat application, in which there is a Spring bean which is declared like
<bean name="PleskXMLInputs" class="<FULLY_QUALIFIED_CLASS_NAME>"
depends-on="registered_shared_ServiceLayersCache">
<property name="slCacheIdentifier" ref="..."/>
</bean>
The xml files containing the declarations are declares included in the web.xml, as follows:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/spring_context.xml
</param-value>
</context-param>
Now the above mentioned bean is used somewhere in the web application. The class does not extend servlet, so I can't use the getServletContext() approach. Is there any way I can read a properties file placed somewhere inside the web application (WEB-INF,WEB-INF/classes, META-INF - anywhere is fine) from inside the bean class?
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14491
|
|
WEB-INF/classes is part of the classpath of the webapp. So any resources placed there can be loaded the same way they would be in a stand-alone Java application, via the classpath resource loader.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
abani patra
Ranch Hand
Joined: Oct 11, 2011
Posts: 70
|
|
Hi ,
You can use the following code snippet in the xml file to use properties files:
|
 |
 |
|
|
subject: Reading file from tomcat, outside servelet.
|
|
|