dev@glassfish.java.net

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

From: Mark Basler <Mark.Basler_at_Sun.COM>
Date: Fri, 08 Sep 2006 11:17:34 -0700

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 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