The moose likes Websphere and the fly likes request.getParameter() returning null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "request.getParameter() returning null" Watch "request.getParameter() returning null" New topic

request.getParameter() returning null

Swetha Raghavendra

Joined: Jun 12, 2010
Posts: 5

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,

Commons file upload servlet:

Swastik Dey

Joined: Jan 08, 2009
Posts: 1579

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

Joined: Jun 12, 2010
Posts: 5
Thanks a lot!! that worked
I agree. Here's the link:
subject: request.getParameter() returning null
It's not a secret anymore!