4 Replies Latest reply on Feb 11, 2008 11:44 AM by trajber

    Richfaces and Servlet Filters

    trajber

      I create a dummy filter and I realize that filter is invoked 3 times. Why ?

      web.xml

      <filter>
       <filter-name>testFilter</filter-name>
       <filter-class>com.mypack.TestFilter</filter-class>
      </filter>
      <filter-mapping>
       <filter-name>testFilter</filter-name>
       <url-pattern>/*</url-pattern>
      </filter-mapping>
      


      TestFilter.java
      public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
       System.out.println("THAT'S IT");
       HttpServletRequest request = (HttpServletRequest) servletRequest;
       System.out.println(request.getRequestURI());
      }
      


      And the output when a request
      THAT'S IT
      /MYTEST/mytest.jsf
      THAT'S IT
      /MYTEST/a4j_3_1_4.GAcss/table.xcss/DATB/eAELvfwiAQAGAQJx.jsf
      THAT'S IT
      /MYTEST/a4j_3_1_4.GAorg.richfaces.renderkit.html.GradientA/DATB/eAF7emTy1lIvAA7XA7E_.jsf

      As you can see the filter is invoked three times and the URI are different.
      Why ?

        • 1. Re: Richfaces and Servlet Filters
          mmichalek

          The page is likely loading other RichFaces resources (css/images, etc.) which are separate requests to your app.

          • 2. Re: Richfaces and Servlet Filters
            trajber

            Hmmm I understand it now.
            But I need to create a Filter that makes my system's authorization and I need to know what page is requested.
            I cannot authorize/validate that ajax's requests. There's a way to do it ?

            • 3. Re: Richfaces and Servlet Filters
              igor_d

              try to use:

              <filter-mapping>
              <filter-name>testFilter</filter-name>
              <servlet-name>Faces Servlet</servlet-name>
              </filter-mapping>

              • 4. Re: Richfaces and Servlet Filters
                trajber

                It does not work. There´s AJAX requests that ends with .jsf, so Faces Servlet will be invoked.

                Example:
                /MYTEST/a4j_3_1_4.GAcss/panel.xcss/DATB/eAF7WBtjAQAF7wHz.jsf

                Is there any way to these requests do not pass through my Filter ?

                "igor_d" wrote:
                try to use:

                <filter-mapping>
                <filter-name>testFilter</filter-name>
                <servlet-name>Faces Servlet</servlet-name>
                </filter-mapping>