It appears that there's something
fundamentally wrong with the new @MultipartConfig annotation.
The documentation says
nothing about where temporary files are stored. All the javadoc
http://docs.oracle.com/javaee/6/api/javax/servlet/annotation/MultipartConfig.html#location()
has to say is:
The directory location where files will be stored. Default:""
Huh? What, exactly, is the location "" ?? Root? Current path?
And the
JEE 6 tutorial is not terribly helpful either:
http://docs.oracle.com/javaee/6/tutorial/doc/gmhal.html
location: An absolute path to a directory on the file system. The location attribute does not support a path relative to the application context. This location is used to store files temporarily while the parts are processed or when the size of the file exceeds the specified fileSizeThreshold setting. The default location is "".
Not terribly illuminating.
Now, suppose that this directory can't be written to. Then the
servlet won't work. Or suppose that the directory is unsuitable for some other reason. Then the programmer can
hard-code a path using the location attribute. But hold on: the webapp may need to run on different platforms (say, Unix and Windows). Then the temp directory must be configurable. But that can't be done using the @MultiPart annotation (afaik). Eek!
A sensible catalog would be to use the System Property "java.io.tmpdir". That should imho be the default, not some undocumented absolute path named "".
Is there
any way of setting location to ${java.io.tmpdir} ??
If not, shouldn't the applicable JSR be amended?