Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a Java web application (myapp.war) which I want do deploy to Tomcat, which is provided by Ubuntu (package tomcat6). This works by placing myapp.jar to the webapps direcotry. This works.

Now, my application has to store some data to local files. My idea was to write to the users home direcotry or to the current work direcotry. But on Ubuntu 10.04 the user is tomcat6, its home is /usr/lib/tomcat6/ and the current work directory is /var/lib/tomcat6/. And both belong to root. Therefore writing is impossible.

So where should a web application store its files?

share|improve this question
    
Also asked and answered on SO stackoverflow.com/questions/3160343/… –  David J. Liszewski Jul 19 '10 at 14:26

2 Answers 2

up vote 0 down vote accepted

I found the solution on Launchpad. /var/lib/tomcat6/webapps/ is writable. This means, that the following works:

File myFile = new File("webapps/myfile.txt");
share|improve this answer

Tomcat can write file anywhere where there is permission for it. You personally should decide where to write your files. This depend strongly on the nature of the data. E.g. you can write to directory /var/www/yourapp/files. There is no common path to store such files for Tomcat webapps.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.