I have the requirement that the user can upload an image along with his other details. So, I created simple html form with enctype of multipart/form-data. I am done with my file upload part. But, when i am trying to get the other values using request.getParameter(fieldName), it is returning null. I have found another way to get the values. And i am able to retrive those values when the enctype is normal one.
I just wanted to know the reason for that. Why request.getParameter is always returning null when the enctype is multipart/form-data is null.
getParameter() and its related methods will not work for a multi-part request.
Whatever upload library you are using will have mechanisms available to get the submitted data. If you are parsing the multi-part request yourself (not recommended) then you aren't doing it right if you haven't located the submitted data.
Thanks bibeault. Actually, I am using the parse method available in upload library only. I would like to know, why getParameter() and its related methods are not getting the values from request. Can anyone explain it?
The HttpServletRequest instance will only parse the body of the request if the enctype is "application/x-www-form-urlencoded", which is the default for the <form> tag.
If it went ahead and read the request body, it would no longer be available for your upload library to fetch and parse.
If you let us know which upload library you are using, perhaps someone can suggest how to use it to obtain the extra parameters.
Hi, "you say you have found another way to get the values." Nowdays I met the same problem ==========Why request.getParameter is always returning null when the enctype is multipart/form-data is null. I wonder how to get the parameters , thank you!!