I am running a Java J2EE app in Tomcat and I would like to upload some files that can be directly served by Tomcat via URL (ie, I don't want to create an additional servlet to serve the files and I don't want to use Apache).
What is the solution to this? I know I should not create files inside the deployed WAR directory (if it is extracted at all), as illustrated in this very old post.
I tried creating another directory under "webapps":
System.getProperty("catalina.base") + "/webapps/uploadedFiles/";
but Tomcat does not seem to serve any file at "localhost:8080/uploadedFiles/...
". So I had to put the files inside the webapps/ROOT directory, were they could be accessed. However, this looks ugly and it's probably not really correct, because I think the ROOT directory is not designed for such purposes.
My question is:
HOW CAN I MAKE TOMCAT SERVE my upload files, considering that they cannot be placed in the deployed directory because they can be overwritten?
Or, what is the same: where should I place my upload files so Tomcat can serve them directly via HTTP request and they don't get overwritten by redeployment?