aspose file tools*
The moose likes Tomcat and the fly likes redploy without lose the created folders Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "redploy without lose the created folders" Watch "redploy without lose the created folders" New topic
Author

redploy without lose the created folders

khaled hanafy
Greenhorn

Joined: Jun 28, 2010
Posts: 25
Hi ,

I have deployed a website in tomcat 7 .This site the users can register and upload some photos and files .

I add new features to my website .The Problem is How can i redploy it without losing the data that users have upload before ?

Thanks in advance .....
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

If your upload folders are external to your WAR, you're fine.

If they are not, congratulations! You've just discovered one of the reasons why I tell people to never write or update information in their WAR.

The only solution for that situation is to take your new WAR, merged in the created information to produce an updated WAR and deploy that.

The only long-term solution for that situation is to relocate your created folders someplace outside of the WAR. Preferably someplace outside of Tomcat, as well.


Customer surveys are for companies who didn't pay proper attention to begin with.
Sumit Bisht
Ranch Hand

Joined: Jul 02, 2008
Posts: 329

May I ask where the user save their photos & data ?
If this happens to be a Database, then nothing would be required.
For I/O operations over the disk, where are you saving ? Also, can you provide the code?
Edit: as tim mentioned, it is helpful to keep the files outside webapps (or tomcat in general) folder itself.
khaled hanafy
Greenhorn

Joined: Jun 28, 2010
Posts: 25
unfortunately, my folder inside the war .I display that uploaded photo and if i create the folder outside tomcat it will be problem for me .


Anyway thanks for your support and fast reply .

Folder creation outside "webapps" folder is enough to solve that issue , right ?


Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

I do not recommend creating your own files and directories in the Tomcat folder. It's possible that you might someday find them conflicting with a newer version of Tomcat. It's even more likely that someone might update Tomcat and you'd lose your folders with no warning whatsoever.

WARs should be considered as Read-Only. Although some webapp servers have the ability to explode the WAR file into a directory tree and modify what's in that directory tree, it is not a right conferred by the J2EE spec, and you violate it at your peril.

You should be using an external data directory. In Linux, a common place to put directories like that is under /var/lib. In Windows, the system documents folder makes a good starting point. For best results, you should not hard-code the document directory path into your WAR - use a web.xml resource definition to define it, JNDI to retrieve it, and a Tomcat Context to set the path that applies to the machine that the webapp is deployed to.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: redploy without lose the created folders