[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.
You guys wanna see my fabulous new place? Or do you wanna look at this tiny ad?
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss


This thread has been viewed 1154 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jul 21, 2018 03:56:50.