모든 인증 관련 작업을 처리하는 필터를 작성하고 있습니다.필터의 응답을 리디렉션하면 IllegalStateException이 throw됩니다.
@Override
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException {
UserSession attribute = (UserSession)request.getSession().getAttribute("user_session_key");
if(attribute!=null && attribute.isValid())
{
//proceed as usual,
chain.doFilter(req, res);
return;
}
else
{
//means the user is not authenticated, so we must redirect him/her to the login page
((HttpServletResponse)res).sendRedirect("loginpage");
return;
}
}
아래와 같이 내 필터는 표준 서블릿 필터입니다하지만이 작업을 수행 할 때, 나는 Tomcat의 ResponseFacade에 의해 슬로우 (자), IllegalStateException를 얻을. 이 필터를 달성하려면 어떻게해야합니까? 다른 SO 스레드에서 TOmcat에서 응답 개체가 이미 커밋되어 있으므로이 문제가 발생했습니다. 어떻게해야합니까?
나는 다른 필터가 응답에 쓰고 있다고 생각하지 않는다. 그리고 내가 체크했을 때, 이것이 첫 번째 필터이다. 그것은 꽤 사소한 것처럼 보이지만 나는 이것을 지나갈 수 없습니다. ( –