The default behavior, in FlowHandlerAdapter.defaultHandleException () , "tries to start a new thread execution with a completed or expired".
It seems like WebFlow's way to do this is to provide a FlowHandler
using the handleException () method that checks for instanceof NoSuchFlowExecutionException
, then do something like create a redirect URL or put something in a session area that can later be deleted after use .
Due to the way WebFlow uses redirects, I donβt think any other areas will allow this flag or message to be used later when a new stream view appears.
However, simply discovering a new session in Interceptor
or even Filter
would seem equally effective. This is what I ultimately did in my previous research on this issue, as described in the related forum topic. I was just hoping for something beautiful.
In addition, by the time the new stream begins, a new session identifier has already been created, so there is no way to initially detect this condition from the .xml stream.
Filter logic example:
if (request.getRequestedSessionId() != null && !request.isRequestedSessionIdValid()) { log.info("Expired Session ID: " + request.getRequestedSessionId()); response.sendRedirect("sessionExpired"); } else { chain.doFilter(request, response); }
Reverse Interceptor:
public class SessionExpiredInterceptor extends HandlerInterceptorAdapter { private String redirectLocation = "sessionExpired"; @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (request.getRequestedSessionId() != null && !request.isRequestedSessionIdValid()) { response.sendRedirect(redirectLocation); return false; } return true; } public String getRedirectLocation() { return redirectLocation; } public void setRedirectLocation(String redirectLocation) { this.redirectLocation = redirectLocation; } }
source share