• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

request.getParameter() returning null

 
Swetha Raghavendra
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm using the commons file upload servlet in my application and below is the HTML file. I want to retrieve all the form fields from the HTML file in the servlet below along with the file uploaded. I tried request.getParameter(), but this returns null. Am I doing something wrong? And I'm not sure why the while loop is executing only once. In my case, shouldn't the while loop run 7 times to get all the input fields? Can someone please help me out.

Thank you,
Swetha.




Commons file upload servlet:


 
Swastik Dey
Rancher
Posts: 1604
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably can't use request.getParameter() with a multipart/form request, that's why you are getting null in the first three console print statements,correct me if I am wrong. 2nd problem is out.close(). You are closing the output stream inside while loop, so it prints the first field name value, output stream is closed, loop continues tries to print again but as the stream is closed leads to an exception.
 
Swetha Raghavendra
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot!! that worked
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic