• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
  • Himai Minh
  • Carey Brown
  • salvin francis

After restart tomcat all uploaded files deleted

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I uploaded my files:

I stored my files in webapp/images. But when the app is redeployed the uploaded files are also getting deleted. How can I solve this problem? When I upload in C:/apache-tomcat-8.0.18/uploads/images/ I can't get images in my jsp , get error Not allowed to load local resource
Posts: 1845
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your solution of storing your files outside of your deployed web application is the correct one.
If you store them within the web app directory, it gets deleted on redploy (as you have noted)

That then raises the question - well how do you access them again?
And the answer to that is: with another servlet.
One that would do the opposite of the one you have written here - read the file from disk, and stream it out on the Servlet response output stream

Like this for example

Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic