commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gaston Escobar" <gesco...@451.com>
Subject [fileupload] Can't resolve example problem
Date Fri, 21 Feb 2003 13:12:26 GMT
I couldn't make fileupload work yet!!

This is the way I'm doing it:
I've got this .html page:

<FORM ENCTYPE="multipart/form-data" ACTION="servlet/UploadServlet"
METHOD=POST>
<INPUT NAME="text1" TYPE="text">
<INPUT NAME="userfile1" TYPE="file">
<INPUT TYPE="submit" VALUE="Send File">
</FORM>

Then I've got this servlet (which is a mixture between the example of
package.html and some
code):


import java.io.*;
import java.util.*;
import java.lang.*;
import org.apache.commons.fileupload.*;
import java.net.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class UploadServlet extends HttpServlet {
 public void doPost(HttpServletRequest req, HttpServletResponse res)
    {

		FileUpload fu = new FileUpload();
        // maximum size before a FileUploadException will be thrown
        fu.setSizeMax(1000000);
        // maximum size that will be stored in memory
        fu.setSizeThreshold(4096);
        // the location for saving data that is larger than
getSizeThreshold()
        fu.setRepositoryPath("../");

	    try {
			System.out.println("aca1");
			List fileItems = fu.parseRequest(req);
			System.out.println("aca2");
			// assume we know there are two files. The first file is a small
			// text file, the second is unknown and is written to a file on
			// the server
			Iterator i = fileItems.iterator();
			String comment = ((FileItem)i.next()).getString();
			FileItem fi = (FileItem)i.next();
			// filename on the client
			String fileName = fi.getName();
			// save comment and filename to database ...
			// write the file
			fi.write("../" + fileName);
		}   catch(FileUploadException fue) {
         fue.printStackTrace();
         System.out.println("There was and error when reading and writing
the file to the server.");
        } catch(Exception e) {
            e.printStackTrace();
        }

    }
}


The servlet throws an exception when it does: List fileItems =
fu.parseRequest(req);


I really don't understand what is happening,


Tomcat's answer is the following:

javax.servlet.ServletException: Servlet execution threw an exception
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:269)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
...

root cause

java.lang.NoClassDefFoundError: org/apache/commons/beanutils/MethodUtils
	at
org.apache.commons.fileupload.FileUpload.getNewInstanceMethod(FileUpload.jav
a:669)
	at org.apache.commons.fileupload.FileUpload.createItem(FileUpload.java:600)
...






 I will really apreciate your help, Please, I need these working as soon as
it is possible!
Thank you very much







Mime
View raw message