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.
On Mon, Dec 2, 2013 at 7:41 PM, Ramirez, Edwin <[email protected]>wrote:
> Hello,
>
> Thank you for your reply. I'll take a look at the example. However, I
> don't use "WebAppContext()", I instead have an AbstractHandler
> implementation. How do I set the configuration of the AbstractHandler
> implementation?
>
> Thanks,
> Edwin S. Ramirez
>
> Date: Mon, 2 Dec 2013 07:13:19 -0700
> From: Joakim Erdfelt <[email protected]>
> To: JETTY user mailing list <[email protected]>
> Subject: Re: [jetty-users] Embedded Jetty Servlet 3.0
> Message-ID:
> <
> cag4zzzdzculr0jivh0+ce5x5ecezwu3_5ofkpccnselk-v9...@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> This example project might help...
>
> https://github.com/jetty-project/embedded-servlet-3.0
>
> Look at the src/test/java/com/company/foo/EmbedMe.java<
> https://github.com/jetty-project/embedded-servlet-3.0/blob/master/src/test/java/com/company/foo/EmbedMe.java
> >
> for
> an example on how to setup the server configuration for various Servlet 3.x
> features.
>
> _______________________________________________
> jetty-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users