<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: attachment code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Mon, 06 Oct 2008 16:41:30 GMT</pubDate>
    <description>DZone Snippets: attachment code</description>
    <item>
      <title>Returning A File As An Attachment From JSP</title>
      <link>http://snippets.dzone.com/posts/show/2096</link>
      <description>// This is truly a snippet. It's a small piece of code you use&lt;br /&gt;// within a JSP file to make sure that the file you are&lt;br /&gt;// returning is not interpreted by the browser. You use this&lt;br /&gt;// when you want to return a TXT file, JPG or other file that&lt;br /&gt;// the browser might open on its own rather than offer a &lt;br /&gt;// dialog to the user so it can be saved.&lt;br /&gt;//&lt;br /&gt;// Note: In this example I'm returning a text file so I set &lt;br /&gt;// the MIME type of the response to text/plain, but you need &lt;br /&gt;// to make sure it matches the type of data you are returning.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;response.setContentType("text/plain");&lt;br /&gt;&lt;br /&gt;response.setHeader("Content-Disposition", "attachment; filename=\"test.txt\"");&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 25 May 2006 01:04:59 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2096</guid>
      <author>JohnMunsch (John Munsch)</author>
    </item>
  </channel>
</rss>
