Re: problem with uploading files
- From: K Gaur <gaurkuber@xxxxxxxxx>
- Date: Fri, 12 Oct 2007 18:59:20 -0700
http://commons.apache.org/fileupload/
Arne
thanks for suggesting but i think i'll need more help
as it hasn't worked out yet
i tried the following code to upload files
to tomcat (web server)
upload1.jsp---->
__________________________________________________________
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Upload 1</title>
</head>
<body>
<form action="http://localhost:8080/CloudscapeDemo/upload2.jsp"
method="post"
enctype="multipart/form-data">
<input type="file" name="docfile1" />
<input type="file" name="docfile2" />
<input type="file" name="docfile3" />
<input type="submit" value="Upload" />
</form>
</body>
</html>
____________________________
and the jsp for handling the uploaded data upload2.jsp is ---->
________________________________________________
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page import="org.apache.commons.fileupload.servlet.*"%>
<%@ page import="org.apache.commons.fileupload.disk.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Upload 2</title>
</head>
<body>
<%
String docfilename = "";
long docsize = 0;
String contentsdf = "";
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload fu = new ServletFileUpload(factory);
List fileItems = fu.parseRequest(request);
out.println("TOTALFILES:" + fileItems.size() + "<br>");
Iterator itr = fileItems.iterator();
fu.setSizeMax(1000000); // throw exception if > 1 Mb
while (itr.hasNext()) {
FileItem fi = (FileItem) itr.next();
if (!fi.isFormField()) {
// only process files here, not form fields
docfilename = fi.getName();
docsize = fi.getSize();
contentsdf = fi.getString();
}
if (docsize > 0) {
out.println("FILENAME:" + docfilename + "<br>");
out.println("FILESIZE:" + docsize + "<br>");
out.println("FILECONTENT:" + contentsdf + "<br>");
}
}
%>
</body>
</html>
____________________________________________
on pressing the submit button tomcat shows following errors:-----
_________________________________
description The server encountered an internal error () that prevented
it from fulfilling this request.
exception
org.apache.jasper.JasperException: javax.servlet.ServletException:
java.lang.NoClassDefFoundError: org/apache/commons/io/output/
DeferredFileOutputStream
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:
541)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:
417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:
320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:
266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/
apache/commons/io/output/DeferredFileOutputStream
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:
850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:
779)
org.apache.jsp.CloudscapeDemo.upload2_jsp._jspService(upload2_jsp.java:
107)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:
70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:
393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:
320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:
266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
____________________________________________
i cannot figure out whether there is a problem with this code
or with my tomcat installation.
kindly help
.
- Follow-Ups:
- Re: problem with uploading files
- From: Arne Vajhøj
- Re: problem with uploading files
- References:
- problem with uploading files
- From: K Gaur
- Re: problem with uploading files
- From: Arne Vajhøj
- problem with uploading files
- Prev by Date: Re: problem with uploading files
- Next by Date: Re: problem with uploading files
- Previous by thread: Re: problem with uploading files
- Next by thread: Re: problem with uploading files
- Index(es):