title: JSP Download Csv File
body: <p>I'm working on the problem for almost one day,and I can't figure out a solution.</p>
  
  <p>I want to add a download service into my jsp page,and the code like this:</p>
  
  <pre><code>response.setHeader("Content-Disposition","attachment;filename=authData"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+".csv");
  
  PrintWriter out = response.getWriter();
  </code></pre>
  
  <p>and I use a trigger button to link to background.and the codes like this:</p>
  
  <pre><code>&lt;input type="submit" class="btn_sure fw" value="query"  onclick="queryAuthDataList();"/&gt; 
  &lt;input type="reset" class="btn_cancel fw" value="reset"&gt; 
  &lt;input type="submit" class="btn_sure fw" value="download CSV" onclick="exportAuthDataList();" &gt;
  </code></pre>
  
  <p>and the following onclick funtion like this:</p>
  
  <pre><code>function exportAuthDataList(){
          $("#queryAuthDataForm").attr("action","export").submit();
          }
      function queryAuthDataList(){
          $("#queryAuthDataForm").attr("action","query").submit();
          }
  </code></pre>
  
  <p><strong>for some reasons , I must use GET to collect the tag names and values in jsp file.</strong></p>
  
  <p>Here comes the problem,when I select data from DB2,and there're many results,I must paging them,<strong>But</strong> when I click next page,it's starting download csv file automaticly.I define different redirect keywords in Jquery,but I can't simplely add jquery function in the "next page" link.Because I may get some other links.</p>
  
  <p>How can I stop the file downloading when I click a different link ?</p>