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 14:57:13 -0700

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