This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Joe Ess
  • salvin francis
  • fred rosenberger

file uploading using Jakarta file upload

Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Awais, I am having the same problem. Did you manage to find a solution?
Posts: 1367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Maximus Decimus Meridius",

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

Kind regards,
Katrina Owen
JavaRanch Saloon Bartender
Ever since I found this suit I've felt strange new needs. And a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!