How to specify location of tomcat temporary folder?
tomcat7
Solution
Use public void setBaseDir(String basedir) method.
"Tomcat needs a directory for temp files. This should be the first method called. By default, if this method is not called, we use: - system properties - catalina.base, catalina.home - $HOME/tomcat.$PORT ..."
import org.apache.catalina.startup.Tomcat;
Tomcat tomcat = new Tomcat();
tomcat.setBaseDir("/mytmpfolder");
tomcat.addWebapp("/mywebapp", "/path/to/mywebapp");
tomcat.start();
tomcat.getServer().await();
Problem
When I start embedded tomcat, it creates a folder name "tomcat." + myportnumber for example: `tomcat.8080`. How can I specify the location of this temp folder. I am using maven, so I want this folder to be in the `target` folder so it will get clean with `mvn clean` command. I am using embedded tomcat version 7.0.26