I'm uploading a CSV file to a Java servlet. My HTML form looks like this :
<form action="upload" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file">
<input type="submit" name="submitBt" id="submitBt">
</form>
In my servlet, I do the following to retrieve the file :
public void uploadCsv(HttpServletRequest request) {
request.getPart("file")
...
}
When a file is set, the servlet does its work and everything is ok.
My problem is, I have a second form in the same JSP. So when a form is submitted, I want to test if the input named "file" containing the CSV file is set or not.
I tried the following :
if (req.getParameter("file") != null)
Always false
if (request.getParameterMap().containsKey("file"))
Always false too
if (req.getPart("file") != null)
Throws an exception if file not set
Help! D: