I have problem with paths in my servlet web application. I'm using java to code the business logic. The problem is that when I run the java code as a java application with main method, I use the relative path to data files dataFiles/myData.json
and it works fine. However, when I run it using Tomcat I have to put the full path from my hard drive ../../../../Documents/workspace/MyApp/dataFiles/myData.json
My directory structure in workspace is:
MyApp
|- src
|-Pkg1
|- some java files and servlet files
|-Pkg2
|- java files
|-dataFiles
|- all data files
|-WebContent
|- jsp pages
|- css
|- js
|- WEB-INF
|- META-INF
The question is: Now I need to create .war file to deploy my application. What is the correct path that I should put before generate war file?