If I add a servlet programmatically via ServletContext.addServlet and also set a MultiPartConfig to allow file upload, the multipartconfig is ignored:
ServletRegistration.Dynamic registration = servletContext.addServlet("myservlet", new MyServlet()); registration.setMultipartConfig(new MultipartConfigElement(...));
As far as I can see the flow of events is as follows:
- servletcontext.addServlet() will create a undertow ServletInfo and a ManagedServlet based on that ServletInfo.
- ManagedServlet does not find a MultiPartConfig in the ServletInfo and therefore does not have a multipart parser.
- The following call registration.setMultipartConfig() does not have any effect for the ManagedServlet
This does not affect Servlets which specify a multipartconfig via an annotation which is picked up by the ServletInfo.