5 Replies Latest reply on May 22, 2005 4:02 PM by sgwood

    Servlet filters not getting executed

    gavinc

      Hi,

      I have a logging filter defined in the web.xml of my portlet whose init method gets called during startup of the portal server.

      I would then expect to see some debug output from every request made inside my portlet but I don't get anything. Breakpoints inside the doFilter method are not hit either.

      I have tried the url pattern set to /*, /portal/*, /web-client/* (the name of my EAR file) and /jsp/* (a root folder of my portlet) all to no avail.

      I'm presuming they are not being hit as the request is initially being processed in the context of portal-core.sar and not my portlet. However, as the filter gets called during startup I would have thought it should be called for every request too.

      So my question is, is it legal to have servlet filters in a portlet, and if so what url mapping do I need to get them invoked?

      I'm using a build of the portal server from the source taken in the middle of last week.

      Any help would be really appreciated as I was hoping to handle my security requirements using filters too!

      Thanks in advance,

      Gav

        • 1. Re: Servlet filters not getting executed

          it is not possible because your filter is applied on your application and is not triggered by jboss portal.

          you need to move the filter to /jboss-portal.sar/portal-server.war/WEB-INF/web.xml

          this raise an interesting question about portlet filters. we could develop portlet filter for portlet that would be executed before the portlet is invoked.

          • 2. Re: Servlet filters not getting executed
            paulhh

            I think this causes us a few headaches. We'd like to be able to use the JSF file upload component from MyFaces - but I think this stops us. Also, we were thinking of doing some security stuff with Acegi, but that too will hit this in the portal.

            Obviously, running our stuff outside the portal is fine - but we'd really like to see it running inside JBoss Portal.

            Perhaps Gavin can give a bit more detail on what the issues are?

            Cheers
            Phh.

            • 3. Re: Servlet filters not getting executed

              paul, why do you need a servlet filter for fileupload in myfaces ?

              • 4. Re: Servlet filters not getting executed
                gavinc

                In MyFaces you need to define their extenstionsFilter to handle the multipart request that a file upload produces.

                If this filter is not called the request arrives at the portal's/MyFaces door in multipart/form-data encoding and not application/x-www-form-urlencoded. The request doesn't get handled propely then and you just remain on the same JSF page!

                I've just replied to a message from Stan regarding this (http://www.jboss.com/index.html?module=bb&op=viewtopic&t=63779) so hopefully he can let me know if there is a different way of doing it!

                We were also hoping to use Acegi for some of our security mechanisms and this also relies on filters being called before the request is actually handled.

                I think the portlet filters stuff may work for the security stuff but not for the multipart requests as those need to be handled real early in the request cycle?

                Cheers,

                Gav

                • 5. Re: Servlet filters not getting executed


                  Any more thoughts on portlet filters?

                  I am integrating an OLAP UI (JPivot) into JBoss Portal. JPivot uses a filter as the controller and JSPs are the views. There are also some servlets that are used for particular functions. A portlet filter that understood filters in the portlet web.xml would be ideal. Then the JBossPortlet subclass for the portlet would be simpler.

                  I have seen the Command subclasses being used in the forums ie. ForumPortlet.init(), but can't find how they are executed. Can you give me some pointers?


                  Thanks,


                  Sherman