This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "problems with forms + multipart/form + servlets" Watch "problems with forms + multipart/form + servlets" New topic

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?

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

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.
I agree. Here's the link:
subject: problems with forms + multipart/form + servlets
Similar Threads
Redirect back to portlet from servlet keeping same parameters
Passing parameters with ENCTYPE=multipart/form-data
how do i get value from input type file in servlet?
how to upload file along with HTML form data
commons FileUpload.