Results 1 to 3 of 3
Thread: Regarding WAR files
- 01-19-2011, 09:46 AM #1Member
- Join Date
- Jan 2011
- Rep Power
Regarding WAR files
I have developed a project for my client which involves uploading images. At present I am storing images within the project, i.e it gets stored within the build folder inside a folder named images. While working in my machine with Netbeans IDE, if I clean and rebuild the project, the images which I had uploaded before also gets deleted. I could actually store the images in a folder outside the project, but it doesn't make sense since while hosting with an external hosting server (like eukhost), I have been allocated a space and I doubt if I could store those images wherever I wish to. This was the problem I faced while developing the project within my machine. So the solution I could find out was never to clean the project.
But now while hosting, if I make slight changes to any files, I will have to deploy a new WAR file. And since my images are stored within the build folder, every time I create a new WAR file, the existing images would get deleted, since for creating the war, don't we have to clean and build the project (this is what I have read somewhere).
I hope you have understood my question. So what is the best solution for me to deploy new war files, so that the images that have been previously uploaded doesn't get deleted.
Thanks in advance.
- 01-20-2011, 03:49 AM #2
probably store the images inside a folder within the user's home folder. your hosting provider runs tomcat as a user, that should have a home directory and be able to write stuff to a folder you could create and maintain images into there ?
for example, an "images" folder inside the user's home folder, where ever this happens to be.
File imagesFolder = new File(System.getProperty("user.home"), "images"); System.out.println("images folder is : " + imagesFolder);
Another idea, might be to store the image files into a database, which is also not inside the application folder.
The only thing that should be stored in the application folder is the application, or anything transient or computed that you can expect to lose when redeploying the application.
- 01-20-2011, 08:52 AM #3Member
- Join Date
- Jan 2011
- Rep Power
Thanks for your reply. Any ways, I have found an easier way to solve this. I would be storing the images in a folder just outside by web app project. and the path for this would be specified in the Context docbase within Tomcat server.xml.
For example, if I am storing the images in D:\images. my server.xml would look like this:
<Context docBase="C:/home/cPanel/public_html/PropertyImages" path="/FinalPropertySolutions/Admin/PropertyImages" />
where the path is the relative position from where I get the images. so wherever I specify this path, the images would actually be taken from D:\images.
This would ideally solve my problem because if I need to further deployments, I need not take care of these images and my deployment would be faster.
Anyways thanks for your suggestion.
- By vinay1497 in forum New To JavaReplies: 8Last Post: 07-30-2010, 05:47 PM
- By 10x2 in forum New To JavaReplies: 12Last Post: 04-30-2010, 11:56 AM
- By itaipee in forum New To JavaReplies: 1Last Post: 02-24-2009, 12:38 PM
- By Farzaneh in forum New To JavaReplies: 2Last Post: 08-27-2008, 03:20 PM
- By christina in forum New To JavaReplies: 1Last Post: 08-06-2007, 04:14 AM