Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can my Servlet receive parameters from a multipart/form-data form?

I have a page that has this piece of code:

<form action="Servlet" enctype="multipart/form-data">
<input type="file" name="file">
<input type="text" name="text1">
<input type="text" name="text2">
</form>

When I use request.getParameter("text1"); in my Servlet it shows null. How can I make my Servlet receive the parameters?

like image 359
Bolaum Avatar asked Dec 28 '22 04:12

Bolaum


1 Answers

All the request parameters are embedded into the multipart data. You'll have to extract them using something like Commons File Upload: http://commons.apache.org/fileupload/

like image 198
gorjusborg Avatar answered Jan 29 '23 21:01

gorjusborg