This is the first time i have used a war file to deploy an application. In the past due to server hosting restrictions i have just copied the directories over.
I am able to create my war file fine through eclipse. From what I have read each time i upload a new war file it will overwrite EVERYTHING from the old one, including all the files and folders when it explodes.
However there is one folder that my application needs to write to. It will be a folder that i upload pictures to. How/Where do I place this folder so it does not get overwritten when i update the war file in the future.
Right now i upload ROOT.war into my webapps folder and the project deploys fine. However the uploadedImages folder always gets overwriten.
Ulf Dittmer wrote:You need to create a directory outside of the web app directory hierarchy.
Ok, then what would my path look like to get to that folder?
It would look exactly like what it looked like when you created it. Perhaps I shouldn't belabour the obvious, but if the path for the directory was "/users/web/data" when you created it then it would be "/users/web/data" when you wanted to use it.
John Schretz wrote:So you are saying instead I should use:
String uploadFolder = "webapps/uploadedImages";
What we are saying is to use the path to the folder. Obviously you can't use getContext() to help with this because the folder you're going to create is not within the application's context. Just use the path to the folder. And don't use a relative path because you don't know what Tomcat's current working directory is. Use the full path to the folder.
One of my favorite rant topics and now you know why. I had a massive number of uploaded image files get nuked because some idiot wrote the app to upload into the WAR.
On a Linux system, the coventional place to upload files for long-term storage would be under the /var directory. Most commonly, someplace like /var/lib/appname, where "appname" is the name of your application.
However, I don't recommend hard-coding this path into the webapp. What I normally do is feed it in as a webapp context variable. If I define the directory path in a Tomcat Context, I can use JNDI to retrieve it.
Customer surveys are for companies who didn't pay proper attention to begin with.