More specifically, I'm using Tomcat 5.5. I've been searching on开发者_如何学编程line for a while and haven't found anything that actually tells me which file I have to update and how. How do I change the default for all applications, and how do I override that for individual applications?
EDIT
I do not want to do it in the code. I want it to be set in the container.
I think I have to modify $CATALINA_HOME/conf/context.xml, but I don't know how.
getServletContext().setAttribute("javax.servlet.context.tempdir","value");
Pathname to a scratch directory to be provided by this Context for temporary read-write use by servlets within the associated web application. This directory will be made visible to servlets in the web application by a servlet context attribute (of type java.io.File) named javax.servlet.context.tempdir as described in the Servlet Specification. If not specified, a suitable directory underneath $CATALINA_HOME/work will be provided.
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html (search for workdir on the above page)
EDIT 1:
CATALINA_HOME/conf/context.xml
<Context ...>
...
<Parameter name="javax.servlet.context.tempdir" value="/xxx/yyy/....."
override="false"/>
...
</Context>
精彩评论