Was wondering if anyone could explain why my log statements in the preHandle method are printing twice?
Here is a code snippet from my subclass of HandlerInterceptorAdaptor
private static final Logger log = Logger.getLogger(HandlerInterceptor.class);
public boolean preHandle(
HttpServletRequest request,
HttpServletResponse response,
Object handler) throws Exception {
HttpSession sess = request.getSession();
String username =(String)sess.getAttribute("ACEGI_SECURITY_LAST_US ERNAME");
if (username != null) {
Authentication auth = SecurityContextHolder.getContext().getAuthenticati on();
if (log.isInfoEnabled()) {
log.info("USERNAME: " + sess.getAttribute("ACEGI_SECURITY_LAST_USERNAME") + " AUTHENTICATED: " + auth.isAuthenticated());
}
}
return true;
}
The above interceptor is a property of my SimpleUrlHandlerMapping, so therefore every request should mean that the interceptor gets called and logs the above statements.
This is working apart from the log statements are printing twice, do I need to override the afterCompletion method instead?
Any help in clarifying this would be appreciated.


Reply With Quote
