Reputation: 105
I have implemented a Filter for a servlet(java). But there is a condition that in some cases i should not be allowing the request to go through( chain.doFilter() ) and allow access to Servlet.
Instead i need to send Error json object back to browser form filter itself. Please let me know how this can be implemented.
Upvotes: 0
Views: 695
Reputation: 280112
Each Filter
has access to the ServletResponse
. Simply get its OutputStream
and use it to write the JSON content. (And don't follow the chain.)
Upvotes: 2