commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Irfan Baig <ir...@abstractedge.com>
Subject Re: [FileUpload] handling FileUploadException causes 'document contains no data' message
Date Wed, 04 Feb 2004 20:27:22 GMT
Hi - just noticed a problem with the example I sent below - I'm 
instantiating DiskFileUpload (as per the example), not FileUpload. So 
the correct example (which is causing my problem) is:

<%
 DiskFileUpload upload = new DiskFileUpload();
 upload.setSizeMax(2000000);
 try{
   List items = upload.parseRequest(request);
 } catch (FileUploadException e){
   out.println("failed: " + e);
 }
out.println("Some random text");
%>


Irfan Baig wrote:

> Hi there - I'm on
> SunOS unknown 5.8 Generic_108528-07 sun4u sparc SUNW,Ultra-5_10
> running this Java: Solaris VM (build Solaris_JDK_1.2.2_07a, native 
> threads, sunwjit)
> and the iPlanet 4.1 webserver.
>
> The FileUpload package works well enough for me, except for one issue 
> - catching the FileUploadException. Here is a portion of code, placed 
> within a JSP, to parse the request. If a FileUploadException is 
> thrown, (e.g. if the file size is too large), I would like the JSP to 
> print a short message, and the error.
>
> <%
>  FileUpload upload = new FileUpload();
>  upload.setSizeMax(2000000);
>  try{
>    List items = upload.parseRequest(request);
>  } catch (FileUploadException e){
>    out.println("failed: " + e);
>  }
> out.println("Some random text");
> %>
>
>
> Now, if the exception is not thrown, this works just fine. The output 
> is 'Some random text'. However, when the exception is thrown, the 
> browser returns a 'Document contains no data'  message (or a  'Page 
> cannot be displayed'  in IE). I would have thought it would have 
> caught the exception, and printed the error message (and then the 
> random text at the bottom). Note that this example has been stripped 
> to the bare minimum to recreate the issue.  In a larger example I've 
> written, FileUpload works great except when encountering this issue - 
> e.g. if a file size exceeds the set limit.
>
> Any ideas what I'm doing wrong here?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message