The javadoc for Part.write()
mentions that:
The file is created relative to the location as specified in the MultipartConfig
My understanding is that for Glassfish, if you don't specify the location, it defaults to the value of:
getServletContext().getAttribute("javax.servlet.context.tempdir")
Which is probably the extra path that you see.
Try specifying the location in the @MultipartConfig
annotation, e.g.:
@MultipartConfig(location="/somepath")
You could set the location to the value of the temp dir, and then just pass the bare filename to the write()
method.