I am trying to get deploy root directory of my servlet based project from java. I am using the following lines of codes to get the path details.
Type 1:
File directory = new File (".");
try {
System.out.println ("Current directory's canonical path: "
+ directory.getCanonicalPath());
System.out.println ("Current directory's absolute path: "
+ directory.getAbsolutePath());
}catch(Exception e) {
System.out.println("Exceptione is ="+e.getMessage());
}
Type 2:
String currentDir = System.getProperty("user.dir");
System.out.println("Current dir using System:" +currentDir);
While executing the above codes from main class i am getting user directory. When i executes from server side, gets as, "Current dir using System:D:\Apache Tomcat 6.0.16\bin". But my project is located in D:\Apache Tomcat 6.0.16\wepapps\SampleStructs
.
Please give me any suggestions for this and help me out of this.