code: @Override
  	public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
  		// try and see if this request is for an HTML page
          HttpServletRequest request = (HttpServletRequest) servletRequest;
  
          String uri = request.getRequestURI();
          final boolean htmlPage = isHtmlPage(uri);
  
          // if this is an HTML page, get the entire contents of the page
          // in a byte-stream
          if (!htmlPage) {
              LOGGER.debug("Not an HTML page for javascript reordering: {}", uri);
              filterChain.doFilter(servletRequest, servletResponse);
              return;
          }
  
          // run through a wrapper response object
          HttpServletResponseWrapperImpl wrapper = new HttpServletResponseWrapperImpl((HttpServletResponse) servletResponse);
          filterChain.doFilter(servletRequest, wrapper);
  
          // check if this is an HTML output
          if (!"text/html".equals(wrapper.getContentType())) {
              LOGGER.debug("Response content not HTML for javascript reordering: {}", uri);
  
              // just write the plain response
              // this is not HTML response
              wrapper.copyToResponse(servletResponse);
              return;
          }
  
          final long startTime = System.currentTimeMillis();
          LOGGER.debug("Javascript reordering candidate found: {}", uri);
  
          writeReorderedHtml(wrapper, servletResponse);
          final long endTime = System.currentTimeMillis();
  
          LOGGER.debug("Reordering javascript for url: {} took: {}ms", uri, (endTime - startTime));
  	}
docs: Move all included JavaScript files to the end of <code>BODY</code> tag in the same order
  that they appeared in the original HTML response.
  
  @param servletRequest
  the incoming {@link ServletRequest} instance
  
  @param servletResponse
  the outgoing {@link ServletResponse} instance
  
  @param filterChain
  the {@link FilterChain} being executed
  
  @throws IOException
  if something fails
  
  @throws ServletException
  if something fails
  
  @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
  javax.servlet.ServletResponse, javax.servlet.FilterChain)