*
The moose likes Servlets and the fly likes how to get the request parameter in a Post method of form enctype=multipart/form-data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to get the request parameter in a Post method of form enctype=multipart/form-data" Watch "how to get the request parameter in a Post method of form enctype=multipart/form-data" New topic
Author

how to get the request parameter in a Post method of form enctype=multipart/form-data

indu yeturu
Ranch Hand

Joined: Aug 27, 2008
Posts: 123
Hi,

I am using <form enc-type=multipart/form-data method="post">
and in the doPost() method of servlet , i am not able to get the request parameters which are used for the jsp page. But it works fine for the Get() method. Is there any specific way to get request parameters, in Post() method once we used multipart/form-data as enc-type ???

thanks
indu


thanks,
indu
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61090
    
  66

How are you processing the multi-part request on the server? With a 3rd-party library?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
indu yeturu
Ranch Hand

Joined: Aug 27, 2008
Posts: 123
I am not using any thirdparty library. Is it needed ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61090
    
  66

So you are parsing the multi-part request using your own code?
indu yeturu
Ranch Hand

Joined: Aug 27, 2008
Posts: 123
Yes Bear , Iam parsing multipart request in one jsp form using POST method, and the receiving servlet will not be able to get the parameters I specified in the form. If I am using the wrong way, please let me know what is the correct way and how to use that third party library..

thanks
indu
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61090
    
  66

The POSTed parameters will be part of the multi-part request. Perhaps your parsing algorithm is not quite correct yet.

In any case, this is hardly an HTML question so I've moved this along to a more appropriate forum.
indu yeturu
Ranch Hand

Joined: Aug 27, 2008
Posts: 123
Now i cleared my own way and am using commons-fileupload 1.2.1 library..
Still getting the

"java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream.."

please can you send me a solution ?

thanks
indu
satish bodas
Ranch Hand

Joined: Jun 19, 2008
Posts: 116
The no class def found error is because at runtime the jar file is not being found.
Place the jar file in the classpath
( web-inf/lib folder of your application )

This will eliminate the no class def found error

Then you can check if the posted data is available to ou.
indu yeturu
Ranch Hand

Joined: Aug 27, 2008
Posts: 123
I already placed it in the classpath..commons-fileupload.jar is sufficient or any other jars are also required?
Bupjae Lee
Ranch Hand

Joined: May 14, 2007
Posts: 107
Library commons-fileupload.jar needs commons-io.jar

You also need to put commons-io.jar in your WEB-INF/lib

See Commons fileUpload page for more information.
[ September 02, 2008: Message edited by: Bupjae Lee ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get the request parameter in a Post method of form enctype=multipart/form-data