dev@woodstock.java.net

Re: ? on upload filter init params

From: Bob Yennaco <Bob.Yennaco_at_Sun.COM>
Date: Wed, 24 Oct 2007 18:08:46 -0400

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
>