Grails Filters not working

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Grails Filters not working

Arsal
Hi,

I have a webservice app and I want to implement a filter. I created a filter class as follows

class MetricFilters {
        def filters = {
                myResponseFilter(uri:'/*'){
                        before = {
                                println 'test'
                        }

and my webservice URL is http://localhost:8080/lodgingcontract/services 

For some reason, it is not picking up filter method, I tried uri:'/*' and uri:'/*/*' but in vain.

Any clues?
Reply | Threaded
Open this post in threaded view
|

Re: Grails Filters not working

Burt Beckwith
Administrator
There are 3 ways to intercept all controller requests:

   myResponseFilter(uri: '/**') {
      before = {
         println 'test'
      }
   }

or

   myResponseFilter(controller:'*', action:'*') {
      before = {
         println 'test'
      }
   }

or

   myResponseFilter() {
      before = {
         println 'test'
      }
   }

Burt

>
> Hi,
>
> I have a webservice app and I want to implement a filter. I created a filter
> class as follows
>
> class MetricFilters {
> def filters = {
> myResponseFilter(uri:'/*'){
> before = {
> println 'test'
> }
>
> and my webservice URL is http://localhost:8080/lodgingcontract/services 
>
> For some reason, it is not picking up filter method, I tried uri:'/*' and
> uri:'/*/*' but in vain.
>
> Any clues?
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://grails-plugins.847840.n3.nabble.com/Grails-Filters-not-working-tp3189705p3189705.html
> To start a new topic under Grails Plugins, email [hidden email]
> To unsubscribe from Grails Plugins, visit
Reply | Threaded
Open this post in threaded view
|

Re: Grails Filters not working

Arsal
Thanks for quick reply. Well when I use the uri: '/**'   the filter works for my http://localhost:8080/lodgingcontract but not for http://localhost:8080/lodgingcontract/services/lodgingcontract.wsdl  I have tried different patterns but unable to find the pattern that works for http://localhost:8080/lodgingcontract/services/lodgingcontract.wsdl which is the URL for my webservice requests.

Any clues?
 
Thanks!
Arsalan


On Thu, Jul 21, 2011 at 7:42 PM, Burt Beckwith [via Grails Plugins] <[hidden email]> wrote:
There are 3 ways to intercept all controller requests:

   myResponseFilter(uri: '/**') {
      before = {
         println 'test'
      }
   }

or

   myResponseFilter(controller:'*', action:'*') {
      before = {
         println 'test'
      }
   }

or

   myResponseFilter() {
      before = {
         println 'test'
      }
   }

Burt

>
> Hi,
>
> I have a webservice app and I want to implement a filter. I created a filter
> class as follows
>
> class MetricFilters {
> def filters = {
> myResponseFilter(uri:'/*'){
> before = {
> println 'test'
> }
>
> and my webservice URL is http://localhost:8080/lodgingcontract/services 
>
> For some reason, it is not picking up filter method, I tried uri:'/*' and
> uri:'/*/*' but in vain.
>
> Any clues?
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://grails-plugins.847840.n3.nabble.com/Grails-Filters-not-working-tp3189705p3189705.html
> To start a new topic under Grails Plugins, email [hidden email]
> To unsubscribe from Grails Plugins, visit


To unsubscribe from Grails Filters not working, click here.

Reply | Threaded
Open this post in threaded view
|

Re: Grails Filters not working

Burt Beckwith
Administrator
Grails filters are wrappers for Spring interceptors, so they only work for controller and GSP requests. To intercept static resource calls like this you need a traditional servlet filter registered in web.xml.

Burt

> Thanks for quick reply. Well when I use the *uri: '/**'*   the filter works
> for my http://localhost:8080/lodgingcontract but not for
> http://localhost:8080/lodgingcontract/services/lodgingcontract.wsdl  I have
> tried different patterns but unable to find the pattern that works for
> http://localhost:8080/lodgingcontract/services/lodgingcontract.wsdl which is
> the URL for my webservice requests.
>
> Any clues?
>
> Thanks!
> Arsalan
>
>
> On Thu, Jul 21, 2011 at 7:42 PM, Burt Beckwith [via Grails Plugins] <
> [hidden email]> wrote:
>
> > There are 3 ways to intercept all controller requests:
> >
> >    myResponseFilter(uri: '/**') {
> >       before = {
> >          println 'test'
> >       }
> >    }
> >
> > or
> >
> >    myResponseFilter(controller:'*', action:'*') {
> >       before = {
> >          println 'test'
> >       }
> >    }
> >
> > or
> >
> >    myResponseFilter() {
> >       before = {
> >          println 'test'
> >       }
> >    }
> >
> > Burt
> >
> > >
> > > Hi,
> > >
> > > I have a webservice app and I want to implement a filter. I created a
> > filter
> > > class as follows
> > >
> > > class MetricFilters {
> > > def filters = {
> > > myResponseFilter(uri:'/*'){
> > > before = {
> > > println 'test'
> > > }
> > >
> > > and my webservice URL is http://localhost:8080/lodgingcontract/services
> >
> > >
> > > For some reason, it is not picking up filter method, I tried uri:'/*' and
> >
> > > uri:'/*/*' but in vain.
> > >
> > > Any clues?
> > >
> > > _______________________________________________
> > > If you reply to this email, your message will be added to the discussion
> > below:
> > >
> > http://grails-plugins.847840.n3.nabble.com/Grails-Filters-not-working-tp3189705p3189705.html
> > > To start a new topic under Grails Plugins, email [hidden email]<http://user/SendEmail.jtp?type=node&node=3189993&i=0>
> > > To unsubscribe from Grails Plugins, visit
> >
> > ------------------------------
> >  If you reply to this email, your message will be added to the discussion
> > below:
> >
> > http://grails-plugins.847840.n3.nabble.com/Grails-Filters-not-working-tp3189705p3189993.html
> >  To unsubscribe from Grails Filters not working, click here<
> >
> >
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
>
http://grails-plugins.847840.n3.nabble.com/Grails-Filters-not-working-tp3189705p3191653.html
> To start a new topic under Grails Plugins, email [hidden email]
> To unsubscribe from Grails Plugins, visit
Reply | Threaded
Open this post in threaded view
|

Re: Grails Filters not working

Arsal
Thanks Burt. I appreciate your quick reply because it saved us some time which I would had spent making my filter work and just banging my head against the wall. After having this info I started working on implementing another Spring Interceptor and it is working good.

~Arsalan

On Fri, Jul 22, 2011 at 1:08 PM, Burt Beckwith [via Grails Plugins] <[hidden email]> wrote:
Grails filters are wrappers for Spring interceptors, so they only work for controller and GSP requests. To intercept static resource calls like this you need a traditional servlet filter registered in web.xml.

Burt

> Thanks for quick reply. Well when I use the *uri: '/**'*   the filter works
> for my http://localhost:8080/lodgingcontract but not for
> http://localhost:8080/lodgingcontract/services/lodgingcontract.wsdl  I have
> tried different patterns but unable to find the pattern that works for
> http://localhost:8080/lodgingcontract/services/lodgingcontract.wsdl which is
> the URL for my webservice requests.
>
> Any clues?
>
> Thanks!
> Arsalan
>
>
> On Thu, Jul 21, 2011 at 7:42 PM, Burt Beckwith [via Grails Plugins] <
> [hidden email]> wrote:

>
> > There are 3 ways to intercept all controller requests:
> >
> >    myResponseFilter(uri: '/**') {
> >       before = {
> >          println 'test'
> >       }
> >    }
> >
> > or
> >
> >    myResponseFilter(controller:'*', action:'*') {
> >       before = {
> >          println 'test'
> >       }
> >    }
> >
> > or
> >
> >    myResponseFilter() {
> >       before = {
> >          println 'test'
> >       }
> >    }
> >
> > Burt
> >
> > >
> > > Hi,
> > >
> > > I have a webservice app and I want to implement a filter. I created a
> > filter
> > > class as follows
> > >
> > > class MetricFilters {
> > > def filters = {
> > > myResponseFilter(uri:'/*'){
> > > before = {
> > > println 'test'
> > > }
> > >
> > > and my webservice URL is http://localhost:8080/lodgingcontract/services
> >
> > >
> > > For some reason, it is not picking up filter method, I tried uri:'/*' and
> >
> > > uri:'/*/*' but in vain.
> > >
> > > Any clues?
> > >
> > > _______________________________________________
> > > If you reply to this email, your message will be added to the discussion
> > below:
> > >
> > http://grails-plugins.847840.n3.nabble.com/Grails-Filters-not-working-tp3189705p3189705.html
> > > To start a new topic under Grails Plugins, email [hidden email]<http://user/SendEmail.jtp?type=node&node=3189993&i=0>
> > > To unsubscribe from Grails Plugins, visit

> >
> > ------------------------------
> >  If you reply to this email, your message will be added to the discussion
> > below:
> >
> >

> >
> >
>
>
> http://grails-plugins.847840.n3.nabble.com/Grails-Filters-not-working-tp3189705p3191653.html

> To start a new topic under Grails Plugins, email [hidden email]
> To unsubscribe from Grails Plugins, visit



To unsubscribe from Grails Filters not working, click here.