title: Ways to send a message from the server to the web browser at any time?
body: <p>I'm in a situation where I want to be able to notify a visitor to my website of an event occurring at the server. </p>
  
  <p>Think:</p>
  
  <ul>
  <li>Website visitor is waiting for an export or report that takes a long time and is running in the background on the server, need to notify visitor when export is done.</li>
  </ul>
  
  <p>or</p>
  
  <ul>
  <li>Website visitor is waiting for a chat message from a sales rep, need to notify visitor when a message is sent to them. </li>
  </ul>
  
  <p>I can think of a few ways to do this: </p>
  
  <ul>
  <li>Keep an HTTP connection to the server
  open forever </li>
  <li>Continually polling the
  HTTP server every second to check if
  there are new messages </li>
  <li>Write a Java
  applet that holds a connection open
  to a Java server process</li>
  </ul>
  
  <p>None of these seem particularly graceful solutions... is there a better way to do this? </p>