aspose file tools*
The moose likes JSP and the fly likes jsp request and form's enctype= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp request and form Watch "jsp request and form New topic
Author

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

liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
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

Joined: Aug 15, 2004
Posts: 2874
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

Joined: Apr 11, 2006
Posts: 134
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

Joined: Aug 15, 2004
Posts: 2874
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.
 
 
subject: jsp request and form's enctype="multipart/form-data" problem