I am using apache-commons-fileupload to get file from client to the server.(using JSP and Servlet).
JSP/HTML
<form method="POST" action="GetFile" enctype="multipart/form-data"> <input type="file" name="datafile"> <input type="text" name="text1"> <input type="submit" value="Next"> </form> Servlet: GetFile
System.out.println(request.getParameter("text1")); I am able to upload the file to the server, but I am not able to get the value of text1 in the servlet (I am getting null value of text1 in the servlet), I need this textfield in the form to submit some additional information while uploading it to the server.
- Is
enctype="multipart/form-data"option of form doesn't allow other form data to be submited? if it doesn't allow it then what are the other options I have to send this additionaltextfieldto theserver. - Or is there any other problem in my code?
name="text1"? Causerequest.getParameter(...)only gets the first value of a parameter, if you have more with the samenameattribute the first one is might empty and therefore null.