How to save generated file temporarily in servlet based web application

Never use relative local disk file system paths in a Java EE web application such as new File(“filename.xml”). For an in depth explanation, see also getResourceAsStream() vs FileInputStream. Never use getRealPath() with the purpose to obtain a location to write files. For an in depth explanation, see also What does servletcontext.getRealPath(“/”) mean and when should … Read more

Relative paths in Python

In the file that has the script, you want to do something like this: import os dirname = os.path.dirname(__file__) filename = os.path.join(dirname, ‘relative/path/to/file/you/want’) This will give you the absolute path to the file you’re looking for. Note that if you’re using setuptools, you should probably use its package resources API instead. UPDATE: I’m responding to … Read more