12 Replies Latest reply: Jun 5, 2012 3:45 AM by Jean-Frederic Clere RSS

Null is passed into doFilter() as the request parameter when the form's enctype="multipart/formdata"

Paweł Ryszawa Newbie

Hi!

 

I encountered the following problem:

 

I created a filter to wrap multipart requests. It's aim is to help override getParameter-like methods in order to translate parts-like parameters to "ordinary" parameters, i.e.:

 

@WebFilter(urlPatterns = { "/*" })

public class MultipartFormDataFilter implements Filter {

   

    @Override

    public void init(FilterConfig fc) throws ServletException {

        //

    }

 

    @Override

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

        HttpServletRequest httpRequest = (HttpServletRequest)request;

        MultipartFormDataRequest multipartRequest = new MultipartFormDataRequest(httpRequest);

        chain.doFilter(multipartRequest, response);

    }

 

    @Override

    public void destroy() {

        //

    }

   

}

 

MultipartFormDataRequest is a simple http servlet request wrapper that overrides getParameter(String), getParameterValues(String), getParameterNames() and getParameterMap() methods.Those methods should return parameters discovered in the request's (so called) parts. The overall mechanism is sucessfully tested with glassfish. However, JBoss "fails" (while glassfish do not) when the form has enctype="multipart/form-data".

 

I really need enctype="multipart/form-data" in my forms, since some business needs require file uploading.

 

Stack trace starts with:

17:19:18,281 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/simik_gen].[FacesServlet]] Servlet.service() for servlet FacesServlet threw exception: java.lang.NullPointerException

        at org.apache.catalina.connector.Request.getParts(Request.java:3233) [:6.0.0.Final]

        at org.apache.catalina.connector.RequestFacade.getParts(RequestFacade.java:1112) [:6.0.0.Final]

 

Does JBoss have a bug? Am I doing something wrong?

 

 

Regards,

Paweł