commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Cooper" <mart...@apache.org>
Subject Re: fileUpload causes getRequestDispatcher(url).forward hanging
Date Wed, 07 Jan 2009 21:14:43 GMT
First, you are invoking the request dispatcher from inside a catch clause,
which is a really bad idea (if it even works).

Second, remember that FileUpload will have consumed the input stream, so
that it will no longer be available to any servlet that you forward to.

--
Martin Cooper


On Wed, Jan 7, 2009 at 12:42 PM, Ha Pham <ha_pb@yahoo.com> wrote:

> Dear all,
>
> I have a small snippet of code as below
>
>           DiskFileItemFactory  factory = new DiskFileItemFactory();
>           ServletFileUpload upload = new ServletFileUpload(factory);
>
>            // maximum size that will be stored in memory
>            factory.setSizeThreshold(10240);
>            // the location for saving data that is larger than
> getSizeThreshold()
>            factory.setRepository(new
> File(System.getProperty("specFolderOnServer")));
>
>            // maximum size before a FileUploadException will be thrown
>
>  upload.setSizeMax(Integer.parseInt(System.getProperty("maxUploadFileSize")));
>
>
>            // Parse the request
>            List<FileItem> items ;
>            try {
>                items = upload.parseRequest(request);
>            } catch (FileUploadException fue) {
>
>               request.getRequestDispatcher(url).forward(request, response);
>            }
>
> When I uploaded a file that exceeds limit size, the program hung at
> request.getRequestDispatcher(url).forward(request, response);
>
> I did some research and found that it relates to the session locking
> somehow, but I could not find a clear suggestion on how to have it resolved.
> Could anyone help me with this issue?
>
> I currently have to remove the line  upload.setSizeMax and check filesize
> limit manually by using method getSize in class FileItem. However, I have a
> feeling that it's more efficient to set max file size in ServletFileUpload
> as the system may not need to copy/save the uploaded file if its size
> exceeds the preset limit. Is this true?
>
> Thank you,
> Ha
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message