title: How to refresh the Java servlet page automatically
body: <p>I am developing a web application based on a Java servlet. </p>
  
  <p>Behind the Java servlet, a thread works. The Java servlet outputs html and java script codes. Thus, html and java script codes dynamically vary by a thread. </p>
  
  <p>I made the following codes. html and javascript codes are output by <code>response.getWriter().println()</code>. </p>
  
  <p>The problem is; when a thread is completed, nothing is shown. 
  However, when I manually refresh the page (Ctrl-R) after a thread is done, I get the page that I expected. </p>
  
  <pre><code>&lt;head&gt;
  &lt;script type=\"text/javascript\"&gt;
  var auto_refresh = setInterval(
  function start()
  {
  $('#load_latest').load('./PubRecommendation' + ' #load_latest');
  }, 2000);
  &lt;/script&gt;           
  &lt;/head&gt;
  
  
  if (result == null) {
      // the variable result is received from a behind thread every 2 seconds. 
      // while a thread is processed
      &lt;div id=\"load_latest\"&gt;
      &lt;p&gt;Currently processing. &lt;p&gt;
      &lt;/div&gt;
  } else {
      // a thread is completed
      &lt;div id="refresh"&gt;
      &lt;p&gt;Process is done. &lt;p&gt;
      &lt;/div&gt;
  }  
  </code></pre>
  
  <p>I already tried <code>location.reload()</code>, but it did not work. </p>