[Logo]
Forums Register Login
filters - getting IllegalStateException
Hi,

I have a web.xml file which has filter mapping something like this:



The code of filter class is something like this:



All filter classes has same kind of code - they redirect to a URL.

I am getting an exception here:



This exception comes when we forward or include request after response is written.

I am not able to figure out what's happening here. Please help.

Thanks.
Simply don't run FilterChain#doFilter() or RequestDispatcher#forward() or RequestDispatcher#include() after the HttpServletResponse#sendRedirect() call.
 
Bauke Scholtz wrote:Simply don't run FilterChain#doFilter() or RequestDispatcher#forward() or RequestDispatcher#include() after the HttpServletResponse#sendRedirect() call.



Thanks. But...

Consider a URL:

http://localhost:8001/mail/a/one

This would be redirected to:

http://localhost:8001/mail/a/two

It's the same pattern so filter called again and again and again...

It's not calling the next filter.
Just check the URL before replacing. If it is subject to replace, then replace and redirect, else continue with request.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Oct 17, 2017 22:20:45.