8 Replies Latest reply on Jun 5, 2012 7:13 AM by khkh82

    SampleFilter Implementation

    khkh82

      Dear,

       

      I've add new sampleFilter to eXo portal, and I want this filter mapped just for PortalLoginController.

       

      So, how could I configure it correctly?

       

      Inlcude desireid xml files to be referenced, and other things associated.

       

      Khaldoun

        • 1. Re: SampleFilter Implementation
          ndkhoiits

          You can refer to sample extension here for more detail

          • 2. Re: SampleFilter Implementation
            khkh82

            Actually, the problem so far not with this part. As I did it before.

             

            The problem is, I need to access ServletContext from SampleFilter which is you know is extended from org.exoplatform.web.filter.Filter which has only one method doFilter, even initiate method won't be executed. (We can get ServletContext from FilterConfig.getServletContext()).

             

            So, what alternative that's eXo could offer us to handle this peice ?

             

            Thanks

            • 3. Re: SampleFilter Implementation
              ndkhoiits

              No, I think there is no way to to get ServletContext from your sample filter which extended from org.exoplatform.web.filter.Filter. However, would u like to let me your problem which impacts to your process, Did you want to get servlet context before access to PortalLoginController?

              • 4. Re: SampleFilter Implementation
                khkh82

                The problem as following:

                I need to do simple integration between java and php by implement php-java-bridge. The main purpose, is just to passing parameter from login jsp page to php corresponding one.

                 

                This process should be handle during Servlet (PortalLoginController), but I had got recomendation to adopt SampleFilter for this instead of modify web.xml related files to obtain continuse support.

                 

                I did this, follow the procedure step by step. But, ServletContext won't be accessable.

                 

                The piece of code is:

                   HttpServletRequest httpRequest = (HttpServletRequest)request;
                   HttpServletResponse httpResponse = (HttpServletResponse)response;
                   RemoteHttpServletContextFactory ctx =
                       new RemoteHttpServletContextFactory(getServlet(),
                                                           getFilterConfig().getServletContext(),
                                                           httpRequest, httpRequest,
                                                           httpResponse);

                 

                Besides, at the end of this code I do simple function

                ctx.handleRequests(httpRequest.getInputStream(),

                                  httpResponse.getOutputStream());

                 

                your support is really appreciated.

                • 5. Re: SampleFilter Implementation
                  ndkhoiits

                  Do you know how RemoteHttpServletContextFactory handle ServletContext within? if it's not necessary an instance of ServletContext, would you like to put null value, or PortalContainerContext (extended from ServletContext) instead of

                  • 6. Re: SampleFilter Implementation
                    khkh82

                    I'll try this and refer you back.

                     

                    But, do their any stucks while implementing ctx.handleRequests(httpRequest.getInputStream(),httpResponse.getOutputStream()); 

                     

                    I mean, any conflict between this and eXo container lifecycle.?

                    • 7. Re: SampleFilter Implementation
                      hoang_to

                      Khaldoun Khashan wrote:

                       

                      I'll try this and refer you back.

                       

                      But, do their any stucks while implementing ctx.handleRequests(httpRequest.getInputStream(),httpResponse.getOutputStream()); 

                       

                      I mean, any conflict between this and eXo container lifecycle.?

                       

                      There might be conflict ( kind of IllegalStateException as both getOutputStream()/getWriter() are invoked on httpResponse object)

                      • 8. Re: SampleFilter Implementation
                        khkh82

                        Minh,

                         

                        So how could we handle this kind of conflict, as long as GateIn Portal show me Illegal header.