0

Mine is JSF 2.2 + primefaces based webapplication which gives facility to upload images. I am storing uploaded images in Resources/images folder of webapp.

When we redeploy new war file, all images are lost. How to solve this? images should be retained across deployments. I am using tomcat 8

please help

Thanks Bhargav

  • 1
    Why don't you save it to a folder that survives a restart? /app/my-great-pp is a good start – serg.nechaev Jun 16 '15 at 04:22
  • 1
    @serg.nechaev is right. Never ever store uploaded images in your webapp. And hence it is not jsf, pf or java related, but a plain tomcat issue – Kukeltje Jun 16 '15 at 06:34

1 Answers1

0

You can create a path which you can access irrespective of your application and it will survive tomcat restart as well. Map a location to a path in server.xml of tomcat

   <Host name="localhost"  appBase="/opt/seamless/www/webapps"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">

  <Context path="/myapplication/pics" docBase="/mylocation/myapplication" />

  </Host>

The docBase in context can be a directory in the system where you want to save your images and path is the application path (http://URL/myapplication/pics)using which you'll be accessing the images like http://URL/myapplication/pics/myimage.jpg.

Sarfaraz Khan
  • 2,166
  • 2
  • 14
  • 29