Java Reference
In-Depth Information
long executionEndTime = System.currentTimeMillis();
StringBuffer logTxt = new StringBuffer
("Execution completed for request - ");
logTxt.append(", handler -");
logTxt.append(", total execution time(ms) -");
logTxt.append((executionEndTime - executionStartTime));;
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
request.setAttribute(START_EXECUTION_TIME_KEY, System.currentTimeMillis());
return true;
The advantage of using the convenience abstract class is evident in Listing 3-44.
I just had to override those methods that are required. Alternatively, using the
HandlerInterceptor , I would need to implement three methods, and the callback
afterCompletion would be redundant. To use this interceptor, it must be associated with
a handler mapping. This is shown in the Spring configuration file (Listing 3-45). Note
that I have used the inner bean style of configuration because this bean is relevant only
in the context of a handler mapping bean.
Listing 3-45. insurance-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
<! - - Other beans - ->
Search WWH ::

Custom Search