title: Forward to a view before servlet processing finishes
body: <p>I'm writing a simple web app that uploads some files to a server, runs some code and then emails the resulting files to the user. However, as the code can take a few hours to run after the user has uploaded some files I would like to forward them to a notification page. They should then be able to close the browser while processing continues on the server and wait for the results email.</p>
  
  <p>After the uploading the files I have this code:</p>
  
  <pre><code>request.setAttribute("notification", details);
  RequestDispatcher view = request.getRequestDispatcher("views/notification.jsp");
  view.forward(request, response);
  </code></pre>
  
  <p>Then the processing code follows. The problem is that the view isn't forwarded until all the processing is finished. Leaving the user hanging on the form page. If the user closes the browser the processing still continues but I would like to forward the user to a notification first.</p>