dev@woodstock.java.net

Re: ? on upload filter init params

From: Bob Yennaco <Bob.Yennaco_at_Sun.COM>
Date: Thu, 25 Oct 2007 11:53:53 -0400

All I can tell you from what I observed from debugging my app is that
the upload does indeed throw an exception with severity SEVERITY_INFO if
maxSize is exceeded, and that associating a <webuijsf:message> with the
upload component does indeed render the appropriate error message.

richard ratta wrote:
> A lot has changed in the implementation of the file upload code.
> A lot of email was exchanged at the time I was addressing problems in
> that code.
>
> Your best be is to read code and documentation in the java files
> to get all the details.
>
> Off the top of my head I can't remember what all the changes were but
> I do believe I stopped the code from throwing exceptions in all but
> the most
> extreme cases. I don't believe the code throws exception if the file
> exceeds max size
> any more.
>
> I do believe there are faces messages queued for this case. Please see
> the java doc
> or actual source for details.
>
> The problem is that there are cases where a message will not be queued
> in time
> for an application to see them. I believe these cases are documented.
>
> -rick
>
> Bob Yennaco wrote:
>
>>
>>
>> richard ratta wrote:
>>
>>>
>>>
>>> Bob Yennaco wrote:
>>>
>>>>
>>>>
>>>> richard ratta wrote:
>>>>
>>>>> good question.
>>>>>
>>>>> I am always amazed how difficult it is to get certain information
>>>>> from
>>>>> a web app's servlet, even when in the servlet. I can't find any.
>>>>>
>>>>> The closest thing I can see is adding listeners that get called
>>>>> when filters
>>>>> and servlets are invoked.
>>>>>
>>>>> Can I ask why you need to know this ?
>>>>
>>>>
>>>> issue #132.
>>>
>>>
>>> So you're gonna force me to waste another 5 minutes of my life
>>> waiting for java.net ;)
>>
>> Well considering I've wasted about 6 hours trying to figure this out
>> ... ;-)
>>
>>>> And so I figured the way to do this was in my validator - compare
>>>> the size of the file to be uploaded with "maxSize" as specified in
>>>> the filter. If it's too big, throw an exception.
>>>
>>>
>>> How can you find out the size of the file you want to upload ?
>>
>> in the validator for the upload, "value" is the UploadFile, and so
>> call getSize() on it.
>>
>>>>
>>>>> Since you are the application developer, you set the value ;)
>>>>
>>>>
>>>> It already is - in the filter.
>>>
>>>
>>> What I meant was "You as the app developer set the value in web.xml"
>>> and therefore you know what it is."
>>> And therefore you don't have to find it at runtime you already know
>>> it, so if want to
>>> display the value just hard code it.
>>
>> I'd rather configure it once and query for it at runtime.
>>
>>>
>>> I don't think you are going to be able to do anything on the client
>>> to prevent an
>>> oversized file from being uploaded.
>>
>> This is all on the server.
>>
>>> Are you sure this code is still throwing exceptions ?
>>
>> Yes. It turns out I can map a <h:message> (or hopefully
>> <webuijsf:message>) to the upload to render the error. Previously I
>> was trying to trap it in my validator and bind an alert's "detail" to
>> a getter which returned my own message. But now I don't even need my
>> own message.
>>
>> Thanx to Deep for his help with this.
>>
>>> Alot has changed, if "132" is any indication of when this issue was
>>> posted.
>>>
>>> -rick
>>>
>>>>
>>>>>
>>>>> -rick
>>>>>
>>>>> Bob Yennaco wrote:
>>>>>
>>>>>>
>>>>>> If I have the following filter config in web.xml
>>>>>>
>>>>>> <filter>
>>>>>> <filter-name>UploadFilter</filter-name>
>>>>>> <filter-class>com.sun.webui.jsf.util.UploadFilter</filter-class>
>>>>>> <init-param>
>>>>>> <param-name>maxSize</param-name>
>>>>>> <param-value>1000000</param-value>
>>>>>> </init-param>
>>>>>> </filter>
>>>>>>
>>>>>> Then can someone tell me what interface I need to use from my app
>>>>>> to get access to the maxSize parameter? If I can get ahold of
>>>>>> the javax.servlet.FilterConfig, then I can call
>>>>>> getInitParameter("maxSize") on it and I'm in business, right? So
>>>>>> then how do I get access to the FilterConfig? I would have
>>>>>> thought that UploadFilter would have a getFilterConfig() method
>>>>>> but it doesn't. Even if it did, how would I get a handle to the
>>>>>> UploadFilter object?
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>>
>>>>>> To unsubscribe, e-mail: dev-unsubscribe_at_woodstock.dev.java.net
>>>>>> For additional commands, e-mail: dev-help_at_woodstock.dev.java.net
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: dev-unsubscribe_at_woodstock.dev.java.net
>>>>> For additional commands, e-mail: dev-help_at_woodstock.dev.java.net
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe_at_woodstock.dev.java.net
>>>> For additional commands, e-mail: dev-help_at_woodstock.dev.java.net
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_woodstock.dev.java.net
>>> For additional commands, e-mail: dev-help_at_woodstock.dev.java.net
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_woodstock.dev.java.net
>> For additional commands, e-mail: dev-help_at_woodstock.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_woodstock.dev.java.net
> For additional commands, e-mail: dev-help_at_woodstock.dev.java.net
>