title: export content to a text file using java with save dialog
body: <p>i have a result set which has got some values, i want to export the data which is there in result set as a text file with the save dialog.</p>
  
  <p>how to do this in java?.</p>
  
  <p>I have done the above requirement for excel and java like the following.</p>
  
  <p><code>response.setContentType("application/vnd.ms-excel");
              response.setHeader("Content-disposition", "attachment; filename=\"" + reportName + ".xls\"");</code></p>
  
  <p>and </p>
  
  <p><code>response.setHeader("Content-disposition", "attachment; filename=\"" + reportName + ".pdf\"");
          response.setContentType("application/pdf");</code></p>
  
  <p>UPDATE :</p>
  
  <pre><code>if(exportTo.equals("text")){
              response.setContentType("text/plain");
              response.setHeader("Content-disposition", "attachment; filename=\"" + reportName + ".txt\"");
              try {
  
              } catch (Exception e) {
                  // TODO: handle exception
              }
  
          }
  </code></pre>
  
  <p>in this </p>
  
  <p>in try block how to set the contents which are avilable from resultset to a output stream and make it available.</p>