anu
anu

Reputation: 1

getParameter() is returning null value with post method

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");
...

Upvotes: 0

Views: 1975

Answers (1)

alexey
alexey

Reputation: 622

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

Upvotes: 1

Related Questions