Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Embedded Jetty Servlet 3.0

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 <edwin.ramirez@xxxxxxxx> 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 <joakim@xxxxxxxxxxx>
To: JETTY user mailing list <jetty-users@xxxxxxxxxxx>
Subject: Re: [jetty-users] Embedded Jetty Servlet 3.0
Message-ID:
        <CAG4zZZDZcULR0JiVH0+Ce5X5EceZwU3_5OfkPCCNSELk-V9Rog@xxxxxxxxxxxxxx>
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
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top