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
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