4

In struts.xml, I have included tokenSession interceptor to my interceptor-stack to validate token for each request. Unfortunately, the same isn't working well for AJAX requests. I got invalid.token response when it executes actionInvocation.invoke().

Hence, I would like to stop executing tokenSession interceptor for AJAX requests (alone). I have a custom interceptor (logging) which get invoked prior to tokenSession interceptor. Is it possible to delete tokenSession interceptor from stack in logging interceptor based on request type (if it is an AJAX request)?

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
Phoenix
  • 41
  • 1

2 Answers2

2

Token interceptor extends MethodFilterInterceptor that means that you can exclude execution of interceptor bases on method names.

In your interceptor stack configure it like that:

<interceptor-ref name="token">
   <param name="excludeMethods">your_ajax_methods_comma_separated</param>
</interceptor-ref>

Another solution is to use different interceptor stack for you AJAX actions.

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
2

Use a different Interceptor Stack for your Action, or use different Interceptor Stacks for different packages, and group all the Actions in the right package.

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243