This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have kept my logger configuration file[config.properties] at /WEB-INF/config folder.But iam unable to read the file from my servlet class. In my servlet iam trying to read the file using path '/WEB-INF/config/config.properties'. Have i placed the file at the right location ? Would it be included in the classpath? Thanks in advance. Nadda
If you mean the CLASSPATH environment setting, servlet containers generally ignore it. Servlet containers also ignore the "current" directory.
Your problem is probably related to the difference between the way the server "sees" application relative paths and the way the operating system sees absolute paths. If you are trying to read a file using typical java.io.File related methods, you need absolute paths.
Originally posted by balakrishnan periysawamy: Normally when you use ResourceBundle or Properties file, server doent look inside the classes folder.
To access any file you need to get the entire path of the file.
This is misleading. Firstly, it depends on whether you want your reference as a File, URL or Stream. If you decide to package code as a library, it makes sense to use the ClassLoader to find resources attached to your code.
If you package as a web application, you may decide to refer to resources relative to the context root, but from experience I prefer to refer to web resources by URL or Stream, since you cannot get an absloute File reference when it is packaged in a WAR file.