ExampleFilter.java 文件源码

java
阅读 38 收藏 0 点赞 0 评论 0

项目:apache-tomcat-7.0.73-with-comment 作者:
/**
 * Time the processing that is performed by all subsequent filters in the
 * current filter stack, including the ultimately invoked servlet.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param chain The filter chain we are processing
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet error occurs
 */
@Override
public void doFilter(ServletRequest request, ServletResponse response,
                     FilterChain chain)
    throws IOException, ServletException {

    // Store ourselves as a request attribute (if requested)
    if (attribute != null)
        request.setAttribute(attribute, this);

    // Time and log the subsequent processing
    long startTime = System.currentTimeMillis();
    chain.doFilter(request, response);
    long stopTime = System.currentTimeMillis();
    filterConfig.getServletContext().log
        (this.toString() + ": " + (stopTime - startTime) +
         " milliseconds");

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号