SECTION: 250-Configuration TITLE: 210tempdir QUESTION: Where are Jetty's temporary directories? Jetty itself has no temporary directories, but each web application can be assigned a temporary directory. If the web application is a WAR file, it may be unpacked to the webapp directory within the web applications temporary directory.

When assigning a temporary directory to a webapplication the following locations are considered:

- The javax.servlet.context.tempdir attribute of the web application is check to see if a directory name or a File has already been set.
- If a WEB-INF/work directory exists, it is used directly.
- If a ${jetty.home}/work directory exists, then a temp directory is created within that directory.
- If no other location has been found, a temporary directory is created within the ${java.io.tmpdir} directory.

If a temporary directory is created, it is given a name based on the first HttpListener within the HttpServer as follows: "jetty_" + listener.getHost() + "_" + listener.getPort() + "_" + virtualHost + "_" + contextPath

Directories created within the java.io.tmpdir are marked as deleteOnExit and are not reused between invocations of the web application context. Other directories, specifically the work directories, are not deleted by Jetty and may be available between runs of the webapplication.

Once a tempory directory has been allocated, a File instance for it is set as the javax.servlet.context.tempdir attribute of the web application.