• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

problem with multipart/form-data

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[That is, given the form:
<FORM ACTION="/servlet/FooServlet"
ENCTYPE="multipart/form-data"
METHOD=POST>

What is your name? <INPUT TYPE=TEXT NAME='submitter'><br>

What file are you sending? <INPUT TYPE=FILE NAME=secretDocument><br>

<input type="submit" value=Submit><br>

</FORM>

I cannot read the submitter using request.getParameter("submitter") (it returns null). ]
Situation:

javax.servlet.HttpServletRequest.getParameter(String) returns null when the ContentType is multipart/form-data
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the standard classes supplied by sun does not suport multipart/form-data (file transfer forms)
give a look at jakarta commons and you will find a set of classes to make file transfer servlets.
 
Loveen Jain
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my problem is not to upload the file....its how to get the value of other fields such as textbox input from a form where one field is for file upload.
request.getparameter returns null.
and if i dont use multipart/form-data then i wont b able to upload the file..
so please tell me the solution to get the value of text fields in servlet.
as request.getparameter() doesn't work. !! i am uploading a file from the same form. so i ll have to use multipart/form-data.....
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right,
Use the commons/fileupload tool that I showed you. It provides methods for retrieving your parameters. getParameter doesn't work with mulit-part forms.
 
I'm still in control here. LOOK at this tiny ad!
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!