I have two web project that use tomcat..this is my directory structure..
webapps
--project1
--WEB-INF
--project2
--WEB-INF
I use commons-fileupload..this is part my code in servlet in project1
String fileName = item.getName();
String root = getServletContext().getRealPath("/");
File path = new File(root + "/uploads");
if (!path.exists()) {
path.mkdirs();
}
File uploadedFile = new File(path + File.separator + fileName);
item.write(uploadedFile);
This will create 'uploads' folder in 'project1' but I want to create 'uploads' folder in 'webapps' because I dont want 'uploads' folder gone when I undeploy 'project1'..
I already try String root = System.getProperty("catalina.base");
but not work..
Can anyone help me...thanks in advance
See Question&Answers more detail:os