0

I have done a lot of cross referencing on this but I don't understand where am I going wrong. I'm using this code while uploading a file. I could upload a file successfully but getParameter() is returning null all the time.

HTML code:

 <form action="uploadingservlet" method="post"
                    enctype="multipart/form-data">
  <input type="text" name="propername" >
  <input type="file" name="file"  >
   <input type="submit" value="Upload File" />
  </form>

Servlet code:

    public class uploadingservlet extends HttpServlet{
    public void doPost(HttpServletRequest request, 
           HttpServletResponse response)
          throws ServletException,IOException {

   isMultipart = ServletFileUpload.isMultipartContent(request);
   fname=request.getParameter("propername");
...
herman
  • 11,740
  • 5
  • 47
  • 58
anu
  • 1
  • 3
  • is the servlet annotated with @MultipartConfig ?? – smoggers Aug 02 '15 at 15:16
  • no I am importing org.apache.commons.. package – anu Aug 02 '15 at 15:44
  • 1
    see here: http://stackoverflow.com/questions/17937841/multipart-form-data-does-not-support-for-request-getparamerter – smoggers Aug 02 '15 at 15:49
  • possible duplicate of [How to upload files to server using JSP/Servlet?](http://stackoverflow.com/questions/2422468/how-to-upload-files-to-server-using-jsp-servlet) – jezrael Aug 02 '15 at 15:58

1 Answers1

1

request.getParameter() doesn't support multi-part requests. It always returns null. You need to use FileUpload. Also look at http://javakart.blogspot.in/2012/11/file-upload-example-using-servlet.html http://www.tutorialspoint.com/servlets/servlets-file-uploading.htm

alexey
  • 622
  • 4
  • 9
  • 2
    does not look like so, see http://stackoverflow.com/questions/2422468/how-to-upload-files-to-server-using-jsp-servlet – M Sach Aug 02 '15 at 16:01