dev@glassfish.java.net

Re: javax.servet.FilterConfig intial parameters don't seem to be passed to filter ...

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Fri, 08 Sep 2006 15:41:02 -0700

Hi Mark,

Mark Basler wrote On 09/08/06 15:00,:

> Hi Jan,
>
> What version of glassfish are you using? I am using glassfish UR1 b6.


I've tried with both the latest v2 as well as v1 UR1 b10.

> I worked around the problem by using the ServletContext, but I really
> don't see why the init-param didn't work.


No, you should not have to work around this.

>
> If you have a later build, I will try it, but if not, I will just
> stick with the workaround...


I'm confident we already have both SQE and TCK coverage for this.
If not, can this be added? cc'ing the relevant folks.


Jan


>
> Please let me know...
>
> Thanks - Mark
>
>
> Jan Luehe wrote:
>
>> Hi Mark,
>>
>> Mark Basler wrote On 09/08/06 11:17,:
>>
>>> Hi Guys,
>>>
>>> I am having trouble retrieving an init-param in a filter for a web
>>> application. My deployment descriptor that is built by netbeans 5.5
>>> 20060907 seems to look correct. I didn't get an error during
>>> deployment, the relevant section is below:
>>>
>>>
>>> <filter>
>>> <filter-name>CaptchaValidateFilter</filter-name>
>>>
>>> <filter-class>com.sun.javaee.blueprints.petstore.controller.CaptchaValidateFilter</filter-class>
>>>
>>> <init-param>
>>> <param-name>entryPages</param-name>
>>>
>>> <param-value>index.html|index.jsp|fileupload.jsp|search.jsp|catalog.jsp|mapAll.jsp|.jpg|.gif</param-value>
>>>
>>> </init-param>
>>> </filter>
>>> <filter>
>>>
>>> The code in the filter is as follows...
>>>
>>> public void init(FilterConfig filterConfig) {
>>> this.filterConfig = filterConfig;
>>> // TEST Code
>>> String
>>> entryPagesParam=filterConfig.getInitParameter("entryPages");
>>> System.out.println("\n*** entry String = " + entryPagesParam);
>>>
>>> for (Enumeration e = filterConfig.getInitParameterNames();
>>> e.hasMoreElements() ;) {
>>> System.out.println("\n*** ParamName=" + e.nextElement());
>>> }
>>>
>>> "*** entry String = nulll" gets printed to the server.log and the
>>> parameters aren't printed from the getInitParameterNames enumeration.
>>
>>
>>
>> I'm unable to reproduce this. I see the init param name and value
>> getting
>> logged just fine.
>>
>> I noticed in your filter declaration, you have a <filter> following
>> the closing
>> </filter>, making your web.xml malformed. But in this case, your webapp
>> would not even deploy ...
>>
>>
>> Jan
>>
>>
>>
>>>
>>> I did try to access the ServerParams by using the code below and all
>>> the servlet parameters printed to the log as expected:
>>>
>>> for (Enumeration e =
>>> filterConfig.getServletContext().getInitParameterNames();
>>> e.hasMoreElements() ;) {
>>> System.out.println("\n*** ParamName=" + e.nextElement());
>>> }
>>>
>>> I searched the bug database and couldn't find and issues.
>>>
>>> Any help would be appreciated...
>>>
>>> Please let me know...
>>>
>>> Thanks - Mark
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>