In some scenarios, I want to force logout. I use Spring Security, and the only way I know how to do this is to redirect / redirect / log out (or any other Spring URL listens for logout attempts). Since, in theory, the user can stop his browser after redirecting, I would prefer to go to the exit URL, since it is very important that the exit logic is executed. Since Spring will always redirect after successful (un) completion, I am wondering if this would be a problem. So, in short, is redirection allowed after the request has already been sent, or will this lead to an IllegalStateException?
So, in short, is redirection allowed after the request has already been redirected, or will this lead to an IllegalStateException?
No, this is absolutely normal. The answer itself does not know about forwarding - it is found exclusively inside the internal parts of the server. Forwarding is simply a mechanism for transferring control internally from one server component to another.
In contrast, you usually cannot redirect after the redirection, since the redirection "completes" the response and is not canceled there.
IllegalStateException, . , , IllegalStateException. , . , . , , Location .
IllegalStateException
Location
MVC JSP , , JSP JSTL <c:redirect>, IllegalStateException. , .
<c:redirect>