Is there a standard place to write temporary files needed for servlets?

John Zukowski

Prior to the Servlets 2.2 API, there was no standard location. The 2.2 API adds the javax.servlet.context.tmpdir attribute to the servlet context that defines where to write something:

File directory = (File)getServletContext().getAttribute("javax.servlet.context.tmpdir");
File file = File.createTempFile("prefix", ".tmp", directory);
FileWriter out = new FileWriter(file);
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact