Results 1 to 3 of 3
  1. #1
    VijayVarghese is offline Member
    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0

    Default Regarding WAR files

    Hi All,

    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.

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    6

    Default

    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.
    Java Code:
    File imagesFolder = new File(System.getProperty("user.home"), "images");
    
    System.out.println("images folder is : " + imagesFolder);
    This would solve the problem for both local development and deployment.
    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.

  3. #3
    VijayVarghese is offline Member
    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0

    Default

    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.

Similar Threads

  1. Replies: 8
    Last Post: 07-30-2010, 05:47 PM
  2. import from dsv files and export to csv files
    By 10x2 in forum New To Java
    Replies: 12
    Last Post: 04-30-2010, 11:56 AM
  3. working with files (text files)
    By itaipee in forum New To Java
    Replies: 1
    Last Post: 02-24-2009, 11:38 AM
  4. Behaving text files like binary files
    By Farzaneh in forum New To Java
    Replies: 2
    Last Post: 08-27-2008, 03:20 PM
  5. how to convert mpeg files to .wav files
    By christina in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 04:14 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •