You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Martin Cooper <ma...@apache.org> on 2003/06/04 19:53:18 UTC

Re: Commons Upload Problems...

It seems that the version of FileUpload you are using is inconsistent with
the code you are writing. You are writing to the new API (good!), but the
version of FileUpload you are using has the old API (bad). If you grab the
latest version of FileUpload, you should be fine. (The RC1 version is up,
it's just not announced yet.)

--
Martin Cooper


On Wed, 4 Jun 2003, Wilson, Allen wrote:

> Hello...
>
>
> I've posted messages in reference to using the FileUpload and it seems
> that I am still having problems. I am now trying to put the class
> together line by line so that if I run into problems I can successfully
> identify the line and try to fix the problem/exception error. Here is
> the code I have so far and it gives me the following error:
>
> javax.servlet.ServletException: Servlet execution threw an exception
>
> With the root cause information of:
>
> java.lang.NoSuchMethodError:
> org.apache.commons.fileupload.DefaultFileItem: method
> (Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;ILjava/io/File;)
> V not found
> 	at
> org.apache.commons.fileupload.DefaultFileItemFactory.createItem(DefaultF
> ileItemFactory.java:231)
> 	at
> org.apache.commons.fileupload.FileUploadBase.createItem(Compiled Code)
> 	at
> org.apache.commons.fileupload.FileUploadBase.parseRequest(Compiled Code)
> 	at FileTransfer.doPost(FileTransfer.java:37)
>
>
> The code:
>
> import java.io.*;
> import java.util.*;
> import javax.servlet.*;
> import java.sql.*;
> import javax.servlet.http.*;
>
> import org.apache.commons.fileupload.*;
>
> public class FileTransfer extends HttpServlet
> {
> 	private String strSQLStart = "Insert into tblPortal Files (";
> 	private String strSQLMid   = " rec_id, dateupload) values (";
> 	private String strSQLEnd   = " Null, curdate())";
>
> 	private String fieldnames =  "";
> 	private String fieldvalues = "";
>
> 	public void doPost(HttpServletRequest req, HttpServletResponse
> res)
> 	throws ServletException, IOException
> 	{
> 	res.setContentType("text/html");
> 	PrintWriter out = res.getWriter();
>
> 	DiskFileUpload upload = new DiskFileUpload();
>
> 	//set paramaters for files
> 	upload.setSizeMax(10000);
> 	upload.setRepositoryPath("/tmp");
>
> 	out.println("<html>");
> 	out.println("<head><title>MARC Research File
> Upload</title></head>");
> 	out.println("<body>");
> 	out.println("File Upload Parameters:");
>
> 	try
> 	{
> 	List uploadItems = upload.parseRequest(req);
> <-------- This is line 37
> 	}
>
> 	catch (FileUploadException fue)
> 	{
> 	fue.printStackTrace(out);
> 	}
>
> 	out.println("</body></html>");
> 	}
> }
>
>
> I am trying to figure my way through it and any help would be
> appreciated.....
>
>
> Thanks....Allen
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org