On 4/23/2019 5:46 PM, Garret Wilson wrote:
3. Since the temporary working directory is on a per-context basis, and I've only set the "basedir" for the entire `Tomcat` instance, Tomcat must be determining a default temporary directory for the context. Surely I'm allowed to explicitly specify a temporary directory on a per-context basis, but I sure can't find it. The `StandardContext` seems to equate the "temporary directory" with the "work directory". Are they really the same? If so, I suppose I can just call `((StandardContext)context).setWorkDir(String)`?


I decided to just change the `Tomcat` base directory to some location. This will let Tomcat create its own per-context temp subdirectory under this, and it lowers the risk that I'll wind up with still other unwanted temporary directories in my project, which is under source control.

It turns out there's another trick here as well. You have to call `tomcat.setBaseDir()` /before/ you call the magic `tomcat.getConnector()` (the latter of which secretly creates the default connector). Otherwise, if the connector is created first, Tomcat decides on its own base directory using the current working directory and something in the form `tomcat:8080` (which is apparently why I got that particular directory subtree in the first place).

Garret

Reply via email to