• 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

jakarta file upload problem

Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a really strange problem trying to upload a file to a servlet.
This is the html page:

Here is the servlet:

When I run the code in Resin, I get a page not available error. If I refresh it, I get the following;

Resin's error.log file has the following error:

If I run the code in Tomcat I get a Http Status 500 error with the same exception.
From what I can tell by looking at the FileUpload source code and the output I receive in Resin, the FileUploadBase.createItem method shouldn't be running since it doesn't seem to be recognizing the Content-Type as multipart/form-data.
Has anyone seen this problem before? Do you have suggestions on what might fix it?
Thanks in advance.
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found my problem. The FileUpload class does not instantiate a FileItemFactory in it's zero parameter constructor. It uses a FileItemFactory during the parsing process and that is what causes the null pointer exception. The solution is to either pass an implementation of the FileItemFactory interface to the constructor of FileUpload (DefaultFileItemFactory is provided with the distribution) or use DiskFileUpload, which is a subclass of FileUpload.
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic