I’m trying to upload an excel in servlet and process it. While uploading I set enctype=“multipart/form-data” in my form. But in my servlet .isMultiPart(request) returns false.
JSP code:
function fSubir()
{
fFreezeButtons();
this.document.forms[0].action="../servlet/renault.saf.demandepiece.demandes.servlet.AjouterPoste";
if (this.document.forms[0].Flag.value == "1")
{
this.document.forms[0].Flag.value = "0";
this.document.forms[0].submit();
}
}
Select .xlsx type File :
<input type="submit" value="upload" onclick="fSubir()"/>
My .Jsp also has another form of get method which doesn’t have any enctype.
Servlet code;
public class AjouterPoste extends SapprServlet{
/**
*
*/
private static final long serialVersionUID = 1L;
private final String UPLOAD_DIRECTORY = "/appli01/safdev01/saf_cl2/test/";
public void performTask(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
System.out.println("inside the AjouterPoste class - performTask");
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
System.out.println("Inside doPost:"+isMultipart+":"+request);
Please find the parts of my code on which I’m trying to upload a file.