wood burning stoves 2.0*
The moose likes Servlets and the fly likes Parsing requests with ENCTYPE= 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 "Parsing requests with ENCTYPE="multipart/form-data"" Watch "Parsing requests with ENCTYPE="multipart/form-data"" New topic
Author

Parsing requests with ENCTYPE="multipart/form-data"

Guy Roth
Ranch Hand

Joined: Aug 09, 2009
Posts: 74
I have got a form that contains both MIME type and textuals parameters. Something like this:

in a jsp file:

In the server side I handle the parameters in doPost in servlet.
I am able to fetch the file that is sent using org.apache.commons.fileupload.servlet.ServletFileUpload
but I can't read the value of the text parameter 'name'

My questions:
1. Do I have to (must) use the 'boundary' attribute when I define the content-type of the form?
2. How can I fetch the simple text parameters from the HttpServletRequest in the server side- should it be also through the special parser ServletFileUpload? because simple call like: request.getParameter("name") - doesn't work (I get null object).

Thanks ahead
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60749
    
  65

getParameter() and its cousins do not work with a multi-part form. You'll need to use the commons upload API.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Guy Roth
Ranch Hand

Joined: Aug 09, 2009
Posts: 74
Thank you for the your response. I will investigate commons upload API.
However, I still would like to know if I have to use the attribute 'boundary' when I use
ENCTYPE="multipart/form-data" to submit the form.

What is the difference between using this attribute and not using this attribute?
 
wood burning stoves
 
subject: Parsing requests with ENCTYPE="multipart/form-data"
 
Similar Threads
executing a javascript function from a servlet
Upload Image to database through Servlet
File Upload
How to create an HTML form in JSP for downloading files?
How can I read parameters from a multipart/form-data upload form?