Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Other Open Source Projects and the fly likes file uploading using Jakarta file upload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "file uploading using Jakarta file upload" Watch "file uploading using Jakarta file upload" New topic

file uploading using Jakarta file upload

Awais Bajwa
Ranch Hand

Joined: Jan 16, 2001
Posts: 191
Hi folks,

I have a JSP containing five ITEMs,

Here is some code of the JSP:

<form name="frmPR" method="post" action="/upload/servlet/UploadServlet" id="frmPR" enctype="multipart/form-data">

<input name="document" id="document" type="file" class="textbox"/> I have five items.

Here is my servlet code:

File repositoryPath=null;
aList uploadedFiles=new ArrayList();
HttpSession session = request.getSession(true);
StringBuffer errors=new StringBuffer();
if (!ServletFileUpload.isMultipartContent(request)){
ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();
diskFileItemFactory.setSizeThreshold(40960); /* the unit is bytes */
List fileItemsList = null;

repositoryPath = new File(Configurations.getRootFileLocation());
servletFileUpload.setSizeMax(Configurations.getMaximumFileSize()); /* the unit is bytes */

try {
fileItemsList = servletFileUpload.parseRequest(request);

When I check the above FileItemList, it returns me the size equal to 0

AM I Missing something:???

[ April 28, 2007: Message edited by: Bear Bibeault ]
Herman Schelti
Ranch Hand

Joined: Jul 17, 2006
Posts: 387
hi Awais,

See the example at

It looks a lot like your code, main difference is that in your code you create a new DiskFileItemFactory() twice, they create it once and then give it to the

ServletFileUpload upload = new ServletFileUpload(factory);

Hope this helps.

Maximus Decimus Meridius

Joined: Aug 13, 2007
Posts: 1
Awais, I am having the same problem. Did you manage to find a solution?
Katrina Owen

Joined: Nov 03, 2006
Posts: 1367
"Maximus Decimus Meridius",

Please check your private messages for an important message from me.

Kind regards,
Katrina Owen
JavaRanch Saloon Bartender
I agree. Here's the link:
subject: file uploading using Jakarta file upload
It's not a secret anymore!