title: grails, how to force the browser to download a file
body: <p>In the controller, I do this to try to get the browser to download a file when the user clicks on a link:</p>
  
  <pre><code>    render( contentType: 'text/csv', text: output);
  </code></pre>
  
  <p>This works in Chrome, but does not work in IE or safari, they just show the data.  Also, it shows the file name as a number (which happened to be the Id on the url, such as www.me.com/show/1</p>
  
  <p>Apparently. the way to fix the download is to convert to an octet stream. This can be done in a htaccess file, but Im not using apache.  Is there any way to do this in grails?  I would imagine its a common scenario.</p>
  
  <p>In php, one might do this:</p>
  
  <pre><code>  header('Content-Disposition: attachment; filename="downloaded.csv"');
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>After reading the two repsonses below (may thanks!) this worked:</p>
  
  <pre><code>response.setHeader "Content-disposition", "attachment; filename=report.csv"
      response.contentType = 'text/csv'
      response.outputStream &lt;&lt; output
      response.outputStream.flush()
  </code></pre>
  
  <p>The amazing thing is that I could take a string and use &lt;&lt; to write it to the output stream. I was going to try to work out how to turn the string it something like a stream.</p>