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.
posted 17 years ago
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.