wood burning stoves 2.0*
The moose likes Servlets and the fly likes problems with forms + multipart/form + servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "problems with forms + multipart/form + servlets" Watch "problems with forms + multipart/form + servlets" New topic
Author

problems with forms + multipart/form + servlets

Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Hi guys.
I have a jsp form with different things (checkboxes, input type, drop down menus, etc), and I also have a file option where the user can select a file from his/her computer.
The request goes to a servlet. After a while I noticed that when I type
String category = request.getParameter("category")
all the values returned are NULL
I also noticed that if I take out the encode type in the form (multipart/form), The values are not null anymore.
What's wrong?? I need to have the encode type in the form because I'm uploading that image in the server.
Any suggestions?
thanks


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

The way data is organised when the encoding type is multipart/form is completely different to the regular encoding.
The problem is that the default decoding can't handle it and therefore returns nothing. You need to get something like the O'Reilly cos package (com.oreilly.servlet) to parse the data to extract the form data including files.
Dave
 
Don't get me started about those stupid light bulbs.
 
subject: problems with forms + multipart/form + servlets
 
Similar Threads
how do i get value from input type file in servlet?
Passing parameters with ENCTYPE=multipart/form-data
how to upload file along with HTML form data
Redirect back to portlet from servlet keeping same parameters
commons FileUpload.