commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Cook <>
Subject Re: fileUpload NullPointerException
Date Fri, 11 Jul 2003 16:49:15 GMT

A null pointer exception on the upload.parseRequest method, which is 
usually the first time that Jakarata.Commons.FileUpload is instantiated, 
typically indicates that the file input form in the HTML is returning a 
blank or a Null value to your servlet.

You can test this by setting up and inputStream to write to a file, or 
System.out.println() to see what in the HTTP header is being returned to 
the servlet

In my extremely limited experience I have found that this is usually 
caused by one of the following:

	o The input form method not being set to POST

	o The input form not being set to "multipart/form-data"

	Example: <form action="yourServletName" method="post" name="step" 

	You can add something like this to check:

	boolean isMultipart = FileUpload.isMultipartContent(req);
         {System.out.println("Return triggered in readInComingData");

	o There is a file upload field that the user is not selecting, and as 
such it is returning a blank or null value to FileUpload.  This would 
usually throw a FileUpload Exception instead though. So I would focus on 
the first two.

> hi, 
> I'm trying to get a servlet running which processes my fileUpload with
> commons-fileUpload following the example on the website. But I always
> get the following NullPointerException although the request is not null:
> java.lang.NullPointerException
> 	at org.apache.commons.fileupload.FileUploadBase.createItem(
> 	at org.apache.commons.fileupload.FileUploadBase.parseRequest(
> 	at de.sourcepark.fileUpload.uploadServlet.doPost(
> 	at javax.servlet.http.HttpServlet.service(
> 	...
> The problem seems to be in the parseRequest method within the doPost of my servlet (=
> List items = upload.parseRequest(request);
> I cannot find the problem and either the solution. I guess it should be something trivial
but I cannot find it. 
> Do you have a suggestions?
> Thanks.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View raw message