0

I have an application using JAX-RS. I upload and save images here :

C:\Java Files\apache-tomcat-7.0.56\wtpwebapps\myApp\images 

Uploading works correctly using this code :

http://www.mkyong.com/webservices/jax-rs/file-upload-example-in-jersey/

but problem is when I publish or sometimes restart server. All images are deleted after publish or sometimes restart of server.

Can anyone tell me solution for this problem ?

G.Ch.
  • 35
  • 6
  • 1
    The problem is that you are storing your images under the wtpwebapps folder. You should store your images to a folder outside the webapp, as the webapp folder can be cleaned/republished. – thedoctor May 13 '15 at 11:11
  • outside the wtpwebapps folder I can reach application via url ? or I need a method to get it ? – G.Ch. May 13 '15 at 11:12
  • You need a special servlet that will then serve the image for you from that location. In the past I have used Apache Web Server to front a Tomcat server and added an alias in Apache to serve the files. – thedoctor May 13 '15 at 11:13
  • Maybe you should use a http server like Apache for providing static resources. – Fran Montero May 13 '15 at 11:13
  • This duplicate, see http://stackoverflow.com/questions/417658/how-to-config-tomcat-to-serve-images-from-an-external-folder-outside-webapps – chokdee May 13 '15 at 11:13
  • Thank you :) I will write a method to "download" it and show in browser – G.Ch. May 13 '15 at 11:14

0 Answers0