Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!
  • 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
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

jsp request and form's enctype="multipart/form-data" problem

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello every one, I'm having a difficulty implementing "multipart/form-data" in my form.
When I use
<FORM name="mail"
action="http://live:8080/jsps/send.jsp"
enctype="multipart/form-data"
method="POST">
the request in send.jsp CAN NOT see any data of the form, and when I pull enctype="multipart/form-data" out of the form, request can access every piece of information in the form. I have to have enctype="multipart/form-data"
in my form for later usage by an Apache library.
Can anyone please tell me what's happening here and IF can I have both - enctype="multipart/form-data" in the form AND have the request accessing the data in the form? Thanks in advance.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
request.getParameter() doesn't work with multipart/form-data.
You can use commons fileupload library. You can retrieve multipart request values by using that library.

Jakarta Commons Fileupload
 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, commons.fileupload libraries by Apache (are these the ones you're talking about?) do use a request for instanciation. And, catch 22, they require multipart to be true when request gets passed as a parameter in order to instanciate the libraries.
So I just don't know what I need to have happening in the form and the code to successfuly use these Apache libraries.
If anyone used commons.fileupload, please respond. Thanks in advance.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by liliya woland:
So I just don't know what I need to have happening in the form and the code to successfuly use these Apache libraries. If anyone used commons.fileupload, please respond. Thanks in advance.



You can write and configure a seperate resource, such as filter, to handle multipart requests. you need is to define your form as multipart/form-data. For more please refer to Using Commons Fileupload.

Cheers.
 
We're being followed by intergalactic spies! Quick! Take this tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!