Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Tomcat/temp directory in Tomcat 7?

Tags:

tomcat

tomcat7

A fresh download of Tomcat 7 (I'm using 7.0.19) contains a 'temp' directory containing the single file, 'safeToDelete.tmp'. What is this directory used for by Tomcat or how is should be used by Tomcat users (developers)?

like image 739
markonian Avatar asked Aug 18 '11 18:08

markonian


1 Answers

When you startup Tomcat, using startup.bat (Windows) or startup.sh, it calls catalina.bat/catalina.sh respectively.

Catalina then needs a temp directory to be set. It does this by setting the CATALINA_TMPDIR variable to TOMCAT_HOME\temp folder and assigns it to java system environment variable as java.io.tmpdir.

This is copied from catalina.bat:

rem   CATALINA_TMPDIR (Optional) Directory path location of temporary directory
rem                   the JVM should use (java.io.tmpdir).  Defaults to
rem                   %CATALINA_BASE%\temp.

Where CATALINA_BASE is TOMCAT_HOME (if run using the startup script).

We carry on:

if not "%CATALINA_TMPDIR%" == "" goto gotTmpdir
set "CATALINA_TMPDIR=%CATALINA_BASE%\temp"

Finally:

if not "%SECURITY_POLICY_FILE%" == "" goto doSecurity
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
goto end
:doSecurity
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
goto end

Finally, the java.io.tmpdir is pointed to the CATALINA_TMPDIR where the JVM write temporary files including disk-based storage policies.

like image 92
Buhake Sindi Avatar answered Sep 30 '22 01:09

Buhake Sindi