code: @Override
      protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
              throws ServletException, IOException {
  
          LocaleContextHolder.setLocale(request.getLocale());
          response = new OutputAwareHttpServletResponse(response);
  
          boolean isIncludeOrForward = WebUtils.isForwardOrInclude(request);
          GrailsWebRequest previous = isIncludeOrForward ? GrailsWebRequest.lookup(request) : null;
          GrailsWebRequest webRequest = new GrailsWebRequest(request, response, getServletContext());
          configureParameterCreationListeners(webRequest);
  
          if (logger.isDebugEnabled()) {
              logger.debug("Bound Grails request context to thread: " + request);
          }
  
          try {
              WebUtils.storeGrailsWebRequest(webRequest);
  
              if(!isIncludeOrForward) {
                  // Set the flash scope instance to its next state. We do
                  // this here so that the flash is available from Grails
                  // filters in a valid state.
                  FlashScope fs = webRequest.getAttributes().getFlashScope(request);
                  fs.next();
              }
  
              // Pass control on to the next filter (or the servlet if
              // there are no more filters in the chain).
              filterChain.doFilter(request, response);
          }
          finally {
              webRequest.requestCompleted();
  
              if(isIncludeOrForward) {
                  if(previous != null) {
                      WebUtils.storeGrailsWebRequest(previous);
                  }
              }
              else {
  
                  WebUtils.clearGrailsWebRequest();
                  LocaleContextHolder.setLocale(null);
              }
              if (logger.isDebugEnabled()) {
                  logger.debug("Cleared Grails thread-bound request context: " + request);
              }
          }
      }
docs: /* (non-Javadoc)
  @see org.springframework.web.filter.OncePerRequestFilter#doFilterInternal(
  javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.FilterChain)