When storing (sensitive) user-specific files in webapp, ensure that you store it somewhere in /WEB-INF
and access them with a Servlet
which (indirectly) checks the logged in user, otherwise it's accessible for any user/hacker on the world wide web. The advantage is that it's easily accessible programmatically by ServletContext#getResource()
or #getRealPath()
. The disadvantage is that they will get lost whenever you redeploy the webapp.
You can also store them in the default temporary folder. The advantage is that it is accessible by standard API's like File#createTempFile()
or System.getProperty("java.io.tmpdir")
. The temporary folder has the disadvantage that OS-controlled folder cleanup is not controllable from Java, so you may risk the stuff getting lost whenever you close the resource but still need it later.
You can also store them in a fixed folder outside the webapp. It has the advantage that the stuff don't get lost whenever you redeploy the webapp. The disadvantage is that you need to create the folder yourself with sufficient OS rights, which may not be applicable in 3rd party hosts.
Cleaning your own temporary resources certainly belongs to the tasks you need to do yourself. I wouldn't consider it as a concern.
Just outweigh the advantages/disadvantages.