[ACCEPTED]-Best practice to save temp files on tomcat?-temp

Accepted answer
Score: 16

Use the property java.io.tmpdir to get the tomcat temp folder 3 and save your files there. That will be 2 a good place to temporarily keep them in. So 1 you can define it as follows:

public static final String TMP_DIR = System.getProperty("java.io.tmpdir")
Score: 9

Either use the property java.io.tmpdir as indicated or 5 use the servlet context attribute javax.servlet.context.tempdir defined 4 in the specification. For tomcat that attribute 3 can be changed by the workDir attribute 2 on the context.

You can use that attribute 1 by a call to servletContext.getAttribute("javax.servlet.context.tempdir")

See tomcat documentation for detail.

Score: 3

Old question, but if there is for creating 1 temp file why not use File.createTempFile function?


File temp = File.createTempFile("real",".howto");

More Related questions