Search code examples
javaservletsmultipartform-datafront-controller

Can a servlet determine if the posted data is multipart/form-data?


I have a servlet that is used for many different actions, used in the Front Controller pattern. Does anyone know if it is possible to tell if the data posted back to it is enctype="multipart/form-data"? I can't read the request parameters until I decide this, so I can't dispatch the request to the proper controller.

Any ideas?


Solution

  • Yes, the Content-type header in the user agent's request should include multipart/form-data as described in (at least) the HTML4 spec:

    http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2