The way we do this is to set the Multipart config on the request manually:
request.setAttribute(Request.__MULTIPART_CONFIG_ELEMENT, new MultipartConfigElement(
System.getProperty("java.io.tmpdir")))
Only thing to watch out for is that you do not make Request parse the parameters (e.g. a call to getParameter("")) before adding the multipart config, as the request parameters are only parsed a single time, so the following is fine:
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
request.setAttribute(Request.__MULTIPART_CONFIG_ELEMENT, new MultipartConfigElement(
System.getProperty("java.io.tmpdir")));
request.getParameter("someparam");
request.getPart("somePart")
}
Rather than doing this in every handler which handles multipart requests, we have a AbstractHandler in a Handler list which checks to see if the request content type is multipart, and if so, adds the above attribute to the request.