简体   繁体   中英

Storing XML Files in Java Project

Apologies for the fairly open question however I feel it needs to be this way.

In any given Java project, preferably a web service, have you ever had to store XML files? At the moment I am creating a Google Web Toolkit web service and I need a way to 'store sessions'( like in iGoogle to store the layout ). However once I have this mechanism down... I need a place to store the files on the server.

I've thought about storing them in the 'Resources' folder in the Java project ( src/main/resources/ ) however something tells me this is impossible as it's deployed to a Tomcat server packaged up in a .war .

Is there any standard way of handling this? Does anyone have any ideas on a way in which I should approach it? In a Python project I have done, I whacked config files straight into /path/to/resources/folder however I feel it doesn't need to be this complicated?!

  • you can designate a configurable external directory for such files.
  • some database systems have XML fields, so you can also store it there
  • you can store it as CLOB in the DB

No this shouldnt need to be complicated, but it is because it depends on whether the server you deploy to allows you access to the file system. If it does, then its easy - just create a data directory, and save the files there.

Otherwise, you can save them as blobs in a database, or whereever your persistence layer is. you face the same problem in python - if you whack the file into /path/to/resources/folder, and you dont have write permission - then your app fails. this problem is not generic to java.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM