in a java class that is in a WEB-INF\classes\some_package, i get the output as 'C:\WINNT\system32'. Why is this so? How do refer to the root directoy of my webapp. ie CATALINA_HOME\webapps\myapp folder? When i try to create a file, it is getting created under the 'C:\WINNT\system32' folder. thanks Sudharsan
You should not rely on this "current directory" ever pointing to anything meaningful when your code is being run in (or as) a server. in particular, some Servlet Containers don't even unpack a web archive file but instead serve files straight from it. If you just need to store some files while your web application is running, al compliant servers provide a "temporary directory" for your use. A File object for this directory is available using the following code in your servlet.
If you need to read files from your web application, you should put them in "WEB-INF/classes" and read them using the "resource" mechanism to find files on the classpath.