Nish
Nish

Reputation: 1012

Invocation of own filter before Struts2 filter

I am trying to invoke a normal servlet filter before the "struts2" filter. If I place my filter declaration above the struts2 filter, I am able to catch my struts based URLs but when this custom filter is placed below the "struts2" filter in web.xml, it is not able to catch the struts based URL(/something.action). Is there any way to invoke my filter apart from placing it on top of "struts2" filter in web.xml ?

Upvotes: 1

Views: 606

Answers (1)

Dave Newton
Dave Newton

Reputation: 160181

The S2 filter ends the filter chain if S2 is supposed to handle the request.

This is because once inside S2 functionality it is assumed additional functionality will be handled by S2, e.g., via interceptors.

This is trivial to change: extend or copy the default S2 filter, update the doFilter method, and restore the chain.doFilter call after the execute.executeAction(request, response, mapping) call (roughly).

You'd need to verify that this works as intended (it should, but I have not tested it).

Upvotes: 1

Related Questions