title: How to generate and download an Excel report using jsp servlet
body: <p>I have generated the Excel report using Apache POI. What I want now, I want to send this to the browser for download. My JSP is as follows.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
    &lt;head&gt;&lt;title&gt; Excel Generator&lt;/title&gt;
      &lt;/head&gt;
    &lt;body&gt;
      &lt;a href="../houseHoldReportGenCtr"&gt;generate report&lt;/a&gt;
    &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here is my servlet code</p>
  
  <pre><code>protected void processRequest(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
  
      String report_path=request.getSession().getServletContext().getInitParameter("REPORT_PATH");
  
      HouseHoldReportGenerator report = new HouseHoldReportGenerator("HOUSE_HOLD",attrStr_,dbParam);
      report.Write_Report___(report_path, dbParam);
      System.out.println("path--&gt;"+report_path+report.getFileName_());}
  </code></pre>
  
  <p>I have my report generation java class as HouseHoldReportGenerator. It generates the report. But What I want from one click on the link in jsp page I want it to be generated and downloaded. I can get the report destination also.</p>