title: Spring MVC - Get HttpServletResponse body
body: <p>Since after 2 days I still cannot figure how to perform a print of a <code>HttpServletResponse</code> body in <code>HandlerInterceptorAdapter</code>, I'll ask another time :)</p>
  
  <p>With <code>HttpServletRequest</code> I can easily do something like <code>request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));</code> and I have the full body but how to make the same with <code>HttpServletResponse</code>?</p>
  
  <p>I Had found lots of question on StackOverflow about that but none of them seems to work.</p>
  
  <p>This is the handler:</p>
  
  <pre><code>@Override
  public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
          throws Exception {
      //how to print here the "response" by using the "response" parameter
      super.afterCompletion(request, response, handler, ex);
  }
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/30491790/how-to-intercept-spring-mvc-serialized-response">this</a> answer is quite the same and links to <a href="https://stackoverflow.com/questions/3242236/capture-and-log-the-response-body">this</a> but they use <code>ServletResponse</code> and NOT <code>HttpServletResponse</code> and something with <code>FilterChain</code> which I have not in my <code>afterCompletion</code> handler. Even <a href="https://stackoverflow.com/questions/8933054/how-to-read-and-copy-the-http-servlet-response-output-stream-content-for-logging">this</a> that seems the most complete one is not suitable (I think) in my case.</p>
  
  <p>Do someone can provide me a simple serialization example with <code>HttpServletResponse</code>?</p>