Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
liliya woland
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.
 
Adeel Ansari
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic