I create a DWR ajaxfilter, but not sure how to config it with Spring. DWR version is 2.0.1, and i hope config it as a globel filter, so when session is expired, i can catch this exception in client side.
package com.gbtags;
import org.directwebremoting.AjaxFilter; import org.directwebremoting.AjaxFilterChain; import org.directwebremoting.WebContextFactory; import org.directwebremoting.extend.LoginRequiredException;
import java.lang.reflect.Method;
public class DWRSessionFilter implements AjaxFilter { public Object doFilter(Object obj, Method method, Object[] params, AjaxFilterChain chain) throws Exception {
//Check if session has timedout/invalidated
if( WebContextFactory.get().getSession( false ) == null ) {
System.out.println("session expired");
//Throw an exception
throw new LoginRequiredException( "This operation requires login." );
}
return chain.doFilter(obj, method, params);
}
}
add filter to dwr.xml as below: