Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ServletFileUpload.isMultipartContent(request) always returns false

843840May 1 2009 — edited May 3 2009
Hello all

I want to build a simple JSP projects that can upload multiple files to server. I have used netbeans 6.5 and tested this code using both tomcat and glassfish server. for this project i have userd Apache Commons Fileupload
.

-----------------

<form action="upload_file.jsp" method="post" enctype="multipart/
form-data" name="form1" id="form1">

<table border="2">
<tr> <td align="center"><b>Multipale file Uploade</td> </tr>

<tr> <td> Specify file: <input name="file" type="file" id="file"><td> </tr>

<tr> <td> Specify file:<input name="file" type="file" id="file"> </td> <tr>

<tr> <td align="center"> <input type="submit" name="Submit" value="Submit files"/> </td> </tr>
</table>

</form>

-----------------

upload_file.jsp :

<%@ page import="java.util.List" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.io.File" %>
<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
<%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<table border="2">
<tr><td><h1>Your files uploaded </h1></td></tr>
<%

boolean isMultipart = ServletFileUpload.isMultipartContent(request);

if (!isMultipart) {
out.println(" Uploading Fail ");
} else {
..........
........
..........
}

%>
</table>

---------------

When i run the code i found that "isMultipart" variable always returns false. it already took a lot of my time while trying to solve but unable to find the problem . Any idea what i am doing wrong here.

thanks in advance

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 31 2009
Added on May 1 2009
2 comments
3,297 views