• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

redploy without lose the created folders

 
khaled hanafy
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18302
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sumit Bisht
Ranch Hand
Posts: 331
Python Ruby Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18302
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic