Spring LogoutHandler: sendRedirect with 302 status
<p>I'm trying to implement spring logoutSuccessHandler.
 when user logout, I redirect call to targetURL with status 302. here is my code to implement this:</p>

<pre><code>  public class LogoutHandler extends SimpleUrlLogoutSuccessHandler {

public LogoutHandler(AuthenticationContext context) {
    this.context = context;
}

@Override
protected void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
        throws IOException, ServletException {
    String targetUrl = "mytarget";

   authentication.setAuthenticated(false);
   response.setStatus(HttpServletResponse.SC_FOUND);

    response.setHeader("Location", targetUrl);
    response.setContentType(MediaType.TEXT_PLAIN_VALUE);
    response.getWriter().write(targetUrl);
    response.getWriter().flush();
    response.getWriter().close();

 }

}
</code></pre>

<p>but this code doesn't work and I have status canceled for this /logout webservice.
How could we implement lougoutHandler?</p>