• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jakarta file upload problem

 
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic