• 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getParameter() and its cousins do not work with a multi-part form. You'll need to use the commons upload API.
 
Guy Roth
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic