jQuery in Action, 3rd edition
The moose likes JSP and the fly likes Problem with org.apache.commons.fileupload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem with org.apache.commons.fileupload" Watch "Problem with org.apache.commons.fileupload" New topic

Problem with org.apache.commons.fileupload

cd rom

Joined: Jan 29, 2005
Posts: 1

I was reading an article about the org.apache.commons.fileupload component

and it just seems not to work for me. I would appreciate your help.

I am using the jar file commons-fileupload-1.0-dev.jar that was downloaded from here:

I work on eclipse and it does not compile.

The first problem is that it cannot find the method isMultipartContent in the following code (taken from your example):

// first check if the upload request coming in is a multipart request
boolean isMultipart = FileUpload.isMultipartContent(request);

I am looking in the eclipse into that jar and it seems like that method is really not in the FileUpload class.

What is wrong?

It is there in the source code, why not in the class.

By the way, when I looked at the jakarta reference here:

and they say this method is deprecated:

"isMultipartContent(HttpServletRequest) - Static method in class org.apache.commons.fileupload.FileUploadBase
Deprecated. Use the method on ServletFileUpload instead."

So why do do you use it in your code.

Also, they say "Use the method on ServletFileUpload instead".

That class is suppposed to be in the package:
import org.apache.commons.fileupload.servlet.*;

But there is not such a subdirectory in the zip source code I downloaded from the jakarta project.

Could you please help me solve these problems.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Why not use the guide on the fileupload site?

If the tutorial you're following is using deprecated methods, then you know it's out of date.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
Thank you for your response,

Of course I was using that tutorial that you are suggesting too.
You can go there and see the Jakarta tutorial is using the FileUpload.isMultipartContent(request) as well. Although here http://jakarta.apache.org/commons/fileupload/apidocs/index-all.html the same Jakarta says this static method is deprecated. They suggest using ServletFileUpload instead. But their refernce says that this method belongs to the class import org.apache.commons.fileupload.servlet.ServletFileUpload which I cannot find in their downloaded code.
When I put in my code the following line:
import org.apache.commons.fileupload.servlet.*;
Eclipse tells me their is no servlet subpackge in my jar.

That leaves me very confused.
Either their distributed code is missing something or I am missing some point.

Could some tell me if he managed to compile on Eclipse a servlet using the commons-fileupload-1.0-dev.jar and the Jakarta tutorial?

We must know, we will know. -- David Hilbert
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63874

"cd rom",

We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Forum Bartender

[Asking smart questions] [About Bear] [Books by Bear]
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
It is setteled.
I am now registered as Joseph Sweet.
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
Does no one have some insight about my questions.

I hope someone could help...
I agree. Here's the link: http://aspose.com/file-tools
subject: Problem with org.apache.commons.fileupload
It's not a secret anymore!