This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with multipart/form-data

 
Loveen Jain
Ranch Hand
Posts: 35
  • 0
  • 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
 
Paulo Pontes
Greenhorn
Posts: 20
  • 0
  • 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
  • 0
  • 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 Redhat VI Editor
  • 0
  • 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 agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic