Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems with uploading files  RSS feed

 
paul Staniland
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm trying to upload some images from a web site and using code off JavaRanch can successfully upload straight from a form using the code in a JSP. My problem arises when I then try and do the same thing in a servlet.

I get a list of errors but they all basically say the same thing:
"package org.apache.commons.fileupload does not exist" when talking about my import statements so I assume it's a classpath problem.

I have added the 2 Jar files into my WEB-INF/lib directory for my application and all my other classpaths and servlets have worked so Javac can obviously access the WEB-INF directory. I've also explicitly added the WEB-INF/lib directory in my classpath variable.

Just wondering why this is not working as a servlet but working fine as a Jsp.

Thanks,
Paul
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66208
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSPs get compiled using the container's classpath, which will include everything in WEB-INF/lib.

Servlets get compiled separately by you. I would suspect that your compilation classpath does not include the jar files.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66208
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've also explicitly added the WEB-INF/lib directory in my classpath variable.
Placing a folder into the classpath will not include jar files within that folder. Each jar file must be explicitly specified.
 
paul Staniland
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear... i'm glad I posted that second comment as explicitly stating the Jar files in the classpath has fixed my problem and it's now uploading beautifully!!

Cheers!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!