title: Send response asynchronously in Spring boot
body: <p>Need to add following functionality to my Spring Boot based REST application: </p>
  
  <p>When a POST method is called, a long running process is started.  At regular intervals (every 5 seconds or so), I need to display a message in the browser to the user, until the process ends.</p>
  
  <p>Note:  This method may not be just called from a browser.  Might be called in the future from a shell script.  The goal is to send response intermittently in the 'response body'.</p>
  
  <p>I tried adding code such as this:</p>
  
  <pre><code>                    OutputStream os = response.getOutputStream();
                      os.write(msg.getBytes());
                      os.flush();
  </code></pre>
  
  <p>But got NullPointer exception while flushing.</p>
  
  <p>How would I do this? Do I have to make an AJAX call or something like that?</p>