views:

107

answers:

1

Hello, I am saving the image at this location :-

private static String photoGalleryPath = "/Common/PhotoGallery/";

I save the image at context.getRealPath(photoGalleryPath)

Everything works fine, but when i clean and build my project. The whole folder of PhotoGallery gets deleted. This looks very funny to me :). Why does it delete my whole folder everytime? And what more should i do to tell the extra smart Glassfish to not to delete my folders?

+1  A: 

You probably should not be storing data within your servlet's webContent directory because (as you observe) redeployment of the WAR may blow it away.

Instead, create a directory somewhere else to hold the images; e.g. /var/yourProject/PhotoGallery/ Alternatively save the images in some kind of database / filestore.

Stephen C
Ok! but if i store it that way, what path should i give to h:graphicImage? because it only expects relative path from our web application. Please help me i am beginner :(What does var mean? do you mean var folder of Ubuntu? How do i give this path to my h:graphicImage?
Ankit Rathod
"/var/yourProject/PhotoGallery/" is an example pathname. Replace it with the (absolute) pathname of the directory where you want to store the images.
Stephen C