commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian K. Wallace" <br...@transmorphix.com>
Subject Re: upload file
Date Fri, 10 Mar 2006 19:42:56 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Are you sure you have the fileupload jars in your classpath
(WEB-INF/lib)? Looks like Tomcat can't find it.


Marc Collin wrote:
> hi
> 
> i try to send only a file with fileupload and save the file to the server
> 
> my jsp file
> <form action="Upload" method="POST" enctypetype="multipart/form-data"> 
>   <input type="file" name="file">
>   <input type="SUBMIT" name="button" value="Envoie">
> </form>
> 
> my servlet
> 
> DiskFileItemFactory factory = new DiskFileItemFactory();
> ServletFileUpload upload = new ServletFileUpload(factory);	
> 
> try{
>   List items = upload.parseRequest(request);
>   Iterator iter = items.iterator();
>   if (iter.hasNext()) {
>     FileItem item = (FileItem) iter.next();
>     System.out.println(item.getName());				
>     File uploadedFile = new File(item.getName());
>     try{
>       item.write(uploadedFile);
>      }catch (Exception e) {
> 	e.printStackTrace();
>      }		
>    } 
> }catch (FileUploadException e) {
>   e.printStackTrace();
> }
> 
> is it the correct way to upload and file file?
> 
> why i try to upload i file i get:
> 
> javax.servlet.ServletException: error cannot instantiate servlet Upload class
> 
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
>         
> org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
>         
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
>         
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
>         
> org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
>         
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
>         java.lang.Thread.run(Thread.java:534)
> 
> 
> java.lang.NoClassDefFoundError: 
> org/apache/commons/fileupload/FileUploadException
>         java.lang.Class.getDeclaredConstructors0(Native Method)
>         java.lang.Class.privateGetDeclaredConstructors(Class.java:1618)
>         java.lang.Class.getConstructor0(Class.java:1930)
>         java.lang.Class.newInstance0(Class.java:278)
>         java.lang.Class.newInstance(Class.java:261)
>         
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
>         
> org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
>         
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
>         
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
>         
> org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
>         
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
>         java.lang.Thread.run(Thread.java:534)
> 
> 
> thanks

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)

iD8DBQFEEdbAaCoPKRow/gARAojBAJ9JgEcsy5R1qDF8MqtMQxgRXxU3bwCffCJA
B19gZFdUXVhL9a6k2f6y5qY=
=ujYo
-----END PGP SIGNATURE-----

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


Mime
View raw message