Reputation: 41
I have a Java Web project, and I'm using Maven with the "src/main/resources" and "src/main/java" folders as the default source folders. The project is actually a RESTful web service and I use Jersey to work with REST resources and api calls.
There's a call in the api (used for testing) that exports some images and xml files (using Photoshop Scripting), uses these xml files to insert data in the DB and then return a success message to the client. After that, the client should be able to get these images using the api.
The problem is that I'm currently exporting the images and xml files to the src/main/resources folder, and the server (Tomcat) only has access to these new files if I clean/republish or restart it, and I guess I can't do that by code. In addition, the database can't be updated since the server can't access the new exported xml files.
Because of that, I tried a different approach, which was putting the images and xml files in the webapp folder of the deployed resources (along with the web pages). It worked as the server didn't need to restart to read the new files. However, in this case I'm using absolute paths to access the xml files in order to update the DB. I searched how to access files in the webapp folder using relative paths, but didn't find anything.
So, first of all, which of the above solutions is the best one to use?
If exporting the files to the resources folder is better, how do I access the new files without restarting the server?
If putting the images/xml files in the webapp folder is better, how do I access them using relative paths?
P.S.: When I export the images and xml files, I use absolute paths in the photoshop script to put them either in the src/main/resources folder or in the webapp folder.
Upvotes: 0
Views: 612
Reputation: 12453
The source folder is not deployed to your server (i hope), the 'webapp' folder isn't a good location too, because it might be deleted on another deployment. You should always divide application and data. So just define an external directory where your server can read/write data.
Upvotes: 2