You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Dave <ja...@yahoo.com> on 2005/11/03 10:31:05 UTC

File upload, exceed limit

I am using FileUpload. In case that file is too large, I like to display a message, but I got the following exception during Restore View phase. How should I catch the exception and display a message? Thanks!
 
01:14:14,156 INFO  [MultipartRequestWrapper] user tried to upload a file that exceeded file-size limitations.
org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because it's size exce
eds allowed range
        at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:317)
        at org.apache.myfaces.component.html.util.MultipartRequestWrapper.parseRequest(MultipartRequestWrapper.java:70)
        at org.apache.myfaces.component.html.util.MultipartRequestWrapper.getParameter(MultipartRequestWrapper.java:151)
        at org.apache.myfaces.context.servlet.RequestParameterMap.getAttribute(RequestParameterMap.java:39)
        at org.apache.myfaces.context.servlet.AbstractAttributeMap.get(AbstractAttributeMap.java:87)
        at org.apache.myfaces.application.jsp.JspStateManagerImpl.getSerializedViewFromServletSession(JspStateManagerImp
l.java:356)
        at org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreTreeStructure(JspStateManagerImpl.java:182)
        at org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:207)
        at org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:255)
        at org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:120)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:67)
        ....
 

		
---------------------------------
 Yahoo! FareChase - Search multiple travel sites in one click.  

Re: File upload, exceed limit

Posted by Mathias Brökelmann <mb...@googlemail.com>.
if the request size is larger than the size specified in the filter
the whole request can not be processed. Not even a single field will
be available in the request. So I wonder how we can solve this problem
though jsf. We can not restore the state of the request (at least if
client side state is used). Even submitted values are not available so
rendering a response with just an error message would be hard since
every field entry will be discarded.

IMO this size limit is just there to prevent that someone (Mr. Evil
;)) uploads really large data. If that limit is exceeded the request
will not be processed and the data will not be transferred.

2005/11/5, Mathias Brökelmann <mb...@googlemail.com>:
> We could drop something into the request and check for that value
> later. Since this message is more a global message I´m currently not
> sure where we should add them to the facescontext messages. Be could
> do this when building the facescontext.
>
> AFAIK the code currently checks the size of the whole response. If a
> user has more than one upload in the page things can get tricky. The
> value which can be specified for the filter is not a value for a
> single file size. It´s more a limit how much data can be send at once
> through a multipartrequest.
>
> I think it is better to use the maxlength attribute of the component
> to validate the uploaded file size. I´ve committed a fix for it since
> since the existing solution depends on the browser which might not
> handle the maxlength attribute correctly and still send larger files.
> The component now validates the size of the uploaded file on server
> side.
>
> 2005/11/5, Martin Marinschek <ma...@gmail.com>:
> > Yes - it would be a normal validation message - the problem is to get
> > it from the filter down to the application, there is no standardized
> > way to do so.
> >
> > regards,
> >
> > Martin
> >
> > On 11/5/05, Robert Parsons <ro...@optushome.com.au> wrote:
> > >  Should it possibly appear as if a normal validation exception? Have a
> > > fileSizeValidator? I dont really know how validators work, just a
> > > suggestion.
> > >
> > >
> > >
> > >  Martin Marinschek wrote:
> > >  That is an old problem we haven't resolved yet.
> > >
> > > What we should do is set a request parameter I think - and on decode,
> > > the fileUpload component checks this request parameter and adds a
> > > message.
> > >
> > > What do you think?
> > >
> > > regards,
> > >
> > > Martin
> > >
> > > On 11/3/05, Dave <ja...@yahoo.com> wrote:
> > >
> > >
> > >  I am using FileUpload. In case that file is too large, I like to display a
> > > message, but I got the following exception during Restore View phase. How
> > > should I catch the exception and display a message? Thanks!
> > >
> > > 01:14:14,156 INFO [MultipartRequestWrapper] user tried to upload a file
> > > that exceeded file-size limitations.
> > > org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException:
> > > the request was rejected because it's size exce
> > > eds allowed range
> > >  at
> > > org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:317)
> > >  at
> > > org.apache.myfaces.component.html.util.MultipartRequestWrapper.parseRequest(MultipartRequestWrapper.java:70)
> > >  at
> > > org.apache.myfaces.component.html.util.MultipartRequestWrapper.getParameter(MultipartRequestWrapper.java:151)
> > >  at
> > > org.apache.myfaces.context.servlet.RequestParameterMap.getAttribute(RequestParameterMap.java:39)
> > >  at
> > > org.apache.myfaces.context.servlet.AbstractAttributeMap.get(AbstractAttributeMap.java:87)
> > >  at
> > > org.apache.myfaces.application.jsp.JspStateManagerImpl.getSerializedViewFromServletSession(JspStateManagerImp
> > > l.java:356)
> > >  at
> > > org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreTreeStructure(JspStateManagerImpl.java:182)
> > >  at
> > > org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:207)
> > >  at
> > > org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:255)
> > >  at
> > > org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:120)
> > >  at
> > > org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:67)
> > >  ....
> > >
> > >
> > >  ________________________________
> > >  Yahoo! FareChase - Search multiple travel sites in one click.
> > >
> > >
> > >
> > >
> > > --
> > >
> > > http://www.irian.at
> > > Your JSF powerhouse -
> > > JSF Trainings in English and German
> > >
> > >
> > >
> > >
> > >
> >
> >
> > --
> >
> > http://www.irian.at
> > Your JSF powerhouse -
> > JSF Trainings in English and German
> >
>
>
> --
> Mathias
>


--
Mathias

Re: File upload, exceed limit

Posted by Mathias Brökelmann <mb...@googlemail.com>.
We could drop something into the request and check for that value
later. Since this message is more a global message I´m currently not
sure where we should add them to the facescontext messages. Be could
do this when building the facescontext.

AFAIK the code currently checks the size of the whole response. If a
user has more than one upload in the page things can get tricky. The
value which can be specified for the filter is not a value for a
single file size. It´s more a limit how much data can be send at once
through a multipartrequest.

I think it is better to use the maxlength attribute of the component
to validate the uploaded file size. I´ve committed a fix for it since
since the existing solution depends on the browser which might not
handle the maxlength attribute correctly and still send larger files.
The component now validates the size of the uploaded file on server
side.

2005/11/5, Martin Marinschek <ma...@gmail.com>:
> Yes - it would be a normal validation message - the problem is to get
> it from the filter down to the application, there is no standardized
> way to do so.
>
> regards,
>
> Martin
>
> On 11/5/05, Robert Parsons <ro...@optushome.com.au> wrote:
> >  Should it possibly appear as if a normal validation exception? Have a
> > fileSizeValidator? I dont really know how validators work, just a
> > suggestion.
> >
> >
> >
> >  Martin Marinschek wrote:
> >  That is an old problem we haven't resolved yet.
> >
> > What we should do is set a request parameter I think - and on decode,
> > the fileUpload component checks this request parameter and adds a
> > message.
> >
> > What do you think?
> >
> > regards,
> >
> > Martin
> >
> > On 11/3/05, Dave <ja...@yahoo.com> wrote:
> >
> >
> >  I am using FileUpload. In case that file is too large, I like to display a
> > message, but I got the following exception during Restore View phase. How
> > should I catch the exception and display a message? Thanks!
> >
> > 01:14:14,156 INFO [MultipartRequestWrapper] user tried to upload a file
> > that exceeded file-size limitations.
> > org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException:
> > the request was rejected because it's size exce
> > eds allowed range
> >  at
> > org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:317)
> >  at
> > org.apache.myfaces.component.html.util.MultipartRequestWrapper.parseRequest(MultipartRequestWrapper.java:70)
> >  at
> > org.apache.myfaces.component.html.util.MultipartRequestWrapper.getParameter(MultipartRequestWrapper.java:151)
> >  at
> > org.apache.myfaces.context.servlet.RequestParameterMap.getAttribute(RequestParameterMap.java:39)
> >  at
> > org.apache.myfaces.context.servlet.AbstractAttributeMap.get(AbstractAttributeMap.java:87)
> >  at
> > org.apache.myfaces.application.jsp.JspStateManagerImpl.getSerializedViewFromServletSession(JspStateManagerImp
> > l.java:356)
> >  at
> > org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreTreeStructure(JspStateManagerImpl.java:182)
> >  at
> > org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:207)
> >  at
> > org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:255)
> >  at
> > org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:120)
> >  at
> > org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:67)
> >  ....
> >
> >
> >  ________________________________
> >  Yahoo! FareChase - Search multiple travel sites in one click.
> >
> >
> >
> >
> > --
> >
> > http://www.irian.at
> > Your JSF powerhouse -
> > JSF Trainings in English and German
> >
> >
> >
> >
> >
>
>
> --
>
> http://www.irian.at
> Your JSF powerhouse -
> JSF Trainings in English and German
>


--
Mathias

Re: File upload, exceed limit

Posted by Martin Marinschek <ma...@gmail.com>.
Yes - it would be a normal validation message - the problem is to get
it from the filter down to the application, there is no standardized
way to do so.

regards,

Martin

On 11/5/05, Robert Parsons <ro...@optushome.com.au> wrote:
>  Should it possibly appear as if a normal validation exception? Have a
> fileSizeValidator? I dont really know how validators work, just a
> suggestion.
>
>
>
>  Martin Marinschek wrote:
>  That is an old problem we haven't resolved yet.
>
> What we should do is set a request parameter I think - and on decode,
> the fileUpload component checks this request parameter and adds a
> message.
>
> What do you think?
>
> regards,
>
> Martin
>
> On 11/3/05, Dave <ja...@yahoo.com> wrote:
>
>
>  I am using FileUpload. In case that file is too large, I like to display a
> message, but I got the following exception during Restore View phase. How
> should I catch the exception and display a message? Thanks!
>
> 01:14:14,156 INFO [MultipartRequestWrapper] user tried to upload a file
> that exceeded file-size limitations.
> org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException:
> the request was rejected because it's size exce
> eds allowed range
>  at
> org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:317)
>  at
> org.apache.myfaces.component.html.util.MultipartRequestWrapper.parseRequest(MultipartRequestWrapper.java:70)
>  at
> org.apache.myfaces.component.html.util.MultipartRequestWrapper.getParameter(MultipartRequestWrapper.java:151)
>  at
> org.apache.myfaces.context.servlet.RequestParameterMap.getAttribute(RequestParameterMap.java:39)
>  at
> org.apache.myfaces.context.servlet.AbstractAttributeMap.get(AbstractAttributeMap.java:87)
>  at
> org.apache.myfaces.application.jsp.JspStateManagerImpl.getSerializedViewFromServletSession(JspStateManagerImp
> l.java:356)
>  at
> org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreTreeStructure(JspStateManagerImpl.java:182)
>  at
> org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:207)
>  at
> org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:255)
>  at
> org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:120)
>  at
> org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:67)
>  ....
>
>
>  ________________________________
>  Yahoo! FareChase - Search multiple travel sites in one click.
>
>
>
>
> --
>
> http://www.irian.at
> Your JSF powerhouse -
> JSF Trainings in English and German
>
>
>
>
>


--

http://www.irian.at
Your JSF powerhouse -
JSF Trainings in English and German

Re: File upload, exceed limit

Posted by Robert Parsons <ro...@optushome.com.au>.
Should it possibly appear as if a normal validation exception? Have a 
fileSizeValidator? I dont really know how validators work, just a 
suggestion.


Martin Marinschek wrote:

>That is an old problem we haven't resolved yet.
>
>What we should do is set a request parameter I think - and on decode,
>the fileUpload component checks this request parameter and adds a
>message.
>
>What do you think?
>
>regards,
>
>Martin
>
>On 11/3/05, Dave <ja...@yahoo.com> wrote:
>  
>
>>I am using FileUpload. In case that file is too large, I like to display a
>>message, but I got the following exception during Restore View phase. How
>>should I catch the exception and display a message? Thanks!
>>
>>01:14:14,156 INFO  [MultipartRequestWrapper] user tried to upload a file
>>that exceeded file-size limitations.
>>org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException:
>>the request was rejected because it's size exce
>>eds allowed range
>>        at
>>org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:317)
>>        at
>>org.apache.myfaces.component.html.util.MultipartRequestWrapper.parseRequest(MultipartRequestWrapper.java:70)
>>        at
>>org.apache.myfaces.component.html.util.MultipartRequestWrapper.getParameter(MultipartRequestWrapper.java:151)
>>        at
>>org.apache.myfaces.context.servlet.RequestParameterMap.getAttribute(RequestParameterMap.java:39)
>>        at
>>org.apache.myfaces.context.servlet.AbstractAttributeMap.get(AbstractAttributeMap.java:87)
>>        at
>>org.apache.myfaces.application.jsp.JspStateManagerImpl.getSerializedViewFromServletSession(JspStateManagerImp
>>l.java:356)
>>        at
>>org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreTreeStructure(JspStateManagerImpl.java:182)
>>        at
>>org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:207)
>>        at
>>org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:255)
>>        at
>>org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:120)
>>        at
>>org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:67)
>>        ....
>>
>>
>> ________________________________
>> Yahoo! FareChase - Search multiple travel sites in one click.
>>
>>
>>    
>>
>
>
>--
>
>http://www.irian.at
>Your JSF powerhouse -
>JSF Trainings in English and German
>
>
>  
>


Re: File upload, exceed limit

Posted by Martin Marinschek <ma...@gmail.com>.
That is an old problem we haven't resolved yet.

What we should do is set a request parameter I think - and on decode,
the fileUpload component checks this request parameter and adds a
message.

What do you think?

regards,

Martin

On 11/3/05, Dave <ja...@yahoo.com> wrote:
> I am using FileUpload. In case that file is too large, I like to display a
> message, but I got the following exception during Restore View phase. How
> should I catch the exception and display a message? Thanks!
>
> 01:14:14,156 INFO  [MultipartRequestWrapper] user tried to upload a file
> that exceeded file-size limitations.
> org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException:
> the request was rejected because it's size exce
> eds allowed range
>         at
> org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:317)
>         at
> org.apache.myfaces.component.html.util.MultipartRequestWrapper.parseRequest(MultipartRequestWrapper.java:70)
>         at
> org.apache.myfaces.component.html.util.MultipartRequestWrapper.getParameter(MultipartRequestWrapper.java:151)
>         at
> org.apache.myfaces.context.servlet.RequestParameterMap.getAttribute(RequestParameterMap.java:39)
>         at
> org.apache.myfaces.context.servlet.AbstractAttributeMap.get(AbstractAttributeMap.java:87)
>         at
> org.apache.myfaces.application.jsp.JspStateManagerImpl.getSerializedViewFromServletSession(JspStateManagerImp
> l.java:356)
>         at
> org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreTreeStructure(JspStateManagerImpl.java:182)
>         at
> org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:207)
>         at
> org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:255)
>         at
> org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:120)
>         at
> org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:67)
>         ....
>
>
>  ________________________________
>  Yahoo! FareChase - Search multiple travel sites in one click.
>
>


--

http://www.irian.at
Your JSF powerhouse -
JSF Trainings in English and German