Skip to content

Instantly share code, notes, and snippets.

@nicholashagen
Created March 14, 2012 21:16
Show Gist options
  • Save nicholashagen/2039581 to your computer and use it in GitHub Desktop.
Save nicholashagen/2039581 to your computer and use it in GitHub Desktop.
Accessing Temporary Directory in Servlet Container
File tmpDir = (File) servletContext.getAttribute(SERVLET_TMP_DIR);
if (tmpDir == null) {
throw new ServletException("Servlet container does not provide temporary directory");
}
File workDir = new File(tmpDir, "classes");
if (!workDir.mkdirs()) {
throw new ServletException("Unable to create classes temporary directory");
}
File test = new File(workDir, test);
// write to file test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment