I am developing a web application which have following directory structure
+-conf (To store the properties and configuration files)
Now, when I deploy the application as a directory (e.g. MyApplication directory is copied into webapps directly) the application is able to pickup property file located in conf folder. It works just fine.
I then tried to create a war file of my application and I disabled the unpackwar option in the server.xml of tomcat 5.5.x. Then I am able to go for static content but my servlets which needs configuration file from conf folder are failing. They throw a FileNotFoundException for the file name. I am locating the configuration file by using
getRealPath("/")+ FILESEPERATOR + "conf" + FILESEPERATOR + "myconf.conf"
am I making mistake somewhere? I need to deploy application in WAR format only!
see the java doc for getRealPath()of ServletContext it says it
The real path returned will be in a form appropriate to the computer and operating system on which the servlet container is running, including the proper path separators. This method returns null if the servlet container cannot translate the virtual path to a real path for any reason (such as when the content is being made available from a .war archive).