Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Jakarta File Upload - ServletFileUpload.parseRequest - NoSuchMethodError

Thread view: 
junk1@davidbevan.co.uk - 23 Feb 2006 22:48 GMT
Im trying to test a simple file upload using Jakartas package, but am
getting the following error...

SRVE0026E: [Servlet
Error]-[org/apache/commons/fileupload/servlet/ServletFileUpload.parseRequest(Lorg/apache/commons/fileupload/RequestContext&#59;)Ljava/util/List&#59;]:
java.lang.NoSuchMethodError:
org/apache/commons/fileupload/servlet/ServletFileUpload.parseRequest(Lorg/apache/commons/fileupload/RequestContext;)Ljava/util/List;

The HTML is...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<META name="GENERATOR" content="IBM WebSphere Studio">
<TITLE>fileupload.html</TITLE>
</HEAD>
<BODY>
<form action="/jlp_wug_WASUG/FileUploadServlet" method="post"
enctype="multipart/form-data">
<INPUT type="file" name="file" size="20">
<INPUT type="text" name="aaaaaa" size="20">
<INPUT type="submit" name="submit">
</form>
<P>Place content here.</P>
</BODY>
</HTML>

and the java is...

package com.johnlewis.wug.wasug.pres.misc;

import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;

import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUpload;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

public class FileUploadServlet extends HttpServlet implements Servlet {

    public void doPost(HttpServletRequest aReq, HttpServletResponse aResp)
throws ServletException, IOException {

        System.out.println("FILE UPLOAD");
//        Check that we have a file upload request
    boolean isMultipart = FileUpload.isMultipartContent(aReq);
    System.out.println("isMultipart:[" + isMultipart + "]");

//        Create a factory for disk-based file items
    DiskFileItemFactory factory = new DiskFileItemFactory();

//        Set factory constraints
    factory.setSizeThreshold(1000000);
    factory.setRepository(new File(""));

//        Create a new file upload handler
    ServletFileUpload upload = new ServletFileUpload(factory);

//        Set overall request size constraint
    upload.setSizeMax(1000000);

//        Parse the request
    try {
        List items = upload.parseRequest(aReq);

//        Process the uploaded items
    Iterator iter = items.iterator();
    while (iter.hasNext()) {
        FileItem item = (FileItem) iter.next();

        if (item.isFormField()) {
            System.out.println("item.getFieldName():[" + item.getFieldName() +
"]");
            System.out.println("item.getString():[" + item.getString() + "]");

        } else {
            System.out.println("item.getFieldName():[" + item.getFieldName() +
"]");
            System.out.println("item.getName():[" + item.getName() + "]");
        }
    }

    }
    catch (FileUploadException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    }
}

Does anyone know why im getting this error?

Thanks

David Bevan
http://www.davidbevan.co.uk
AlexCheng1982@gmail.com - 24 Feb 2006 04:31 GMT
try re-download the commons fileupload package


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.