I need to write an interceptor/filter in my spring-jersey application, which will check every request for session and on success it will pass a code to respective controller. Passing this code is imp, because based on the code controller will decide further action.
Q:
1) Is this possible to write this kind of login filter in Spring? How?
2) Is this possible to pass some code to controller from interceptor? How?
We need to implement ContainerRequestFilter interface for creating Jersey filter. Following is the code sample for intercepting and modifying a request using jersey filter:
After adding this class, we need to register this filter for our web application. So now we will add following lines in our web.xml: