• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Upload in Tomcat 7- Uploaded files are deleted automatically after redeploying the application

 
Sandeep Panda
Greenhorn
Posts: 8
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am using Servlet 3.0 and MultipartConfig annotation(Using Parts) to upload files. The upload Servlet works perfectly but as soon as the app is redeployed the uploaded files are also getting deleted. I am storing the uploaded files in /WEB-INF/uploads directory of the web app. Please let me know why the files are getting deleted after redeploying the app.

Any suggestions will be highly appreciated.

Regards!
 
Koen Aerts
Ranch Hand
Posts: 344
Java Linux Oracle
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should never upload files to the web work folder. Files should be uploaded outside of the web app location.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why you should be surprised that when you redeploy the web app, the files are replaced? Anything in the web app is removed and replaced with the new deployment.

As has already been pointed out a number of times in the past week (you really should be reading all posts in this forum) never stored files inside the web app.
 
Sandeep Panda
Greenhorn
Posts: 8
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh my bad..I got it..it is such a common concept..
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keep in mind of the fact that during deployment your WAR file gets extracted afresh if not done.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic