Reputation: 1
I have done a lot of cross referencing on this but I don't understand where am I going wrong. I'm using this code while uploading a file. I could upload a file successfully but getParameter()
is returning null all the time.
HTML code:
<form action="uploadingservlet" method="post"
enctype="multipart/form-data">
<input type="text" name="propername" >
<input type="file" name="file" >
<input type="submit" value="Upload File" />
</form>
Servlet code:
public class uploadingservlet extends HttpServlet{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,IOException {
isMultipart = ServletFileUpload.isMultipartContent(request);
fname=request.getParameter("propername");
...
Upvotes: 0
Views: 1975
Reputation: 622
request.getParameter() doesn't support multi-part requests. It always returns null. You need to use FileUpload. Also look at http://javakart.blogspot.in/2012/11/file-upload-example-using-servlet.html http://www.tutorialspoint.com/servlets/servlets-file-uploading.htm
Upvotes: 1