Rather than using getRealPath, I would suggest that you find out a directory on the server that your provider lets you write to, and include it as a property in your web app.
ie rather than using the ServletContext getRealPath method, retrieve it from a parameter you have set.
Agreed, it makes the installation of your site more complicated, as you now need to configure an additional piece of information somewhere, but it does have the advantage that you can specify anywhere - not just within the application path.
Possible places to put the property:
- in a properties file under the WEB-INF directory
- in the web.xml as a context property
- in a database