title: save as dialog in jsp
body: <p>In my JSP page i had created a button(Download Result) and when i click the button it will display the save as dialog box. User will select a path to store the downloaded file. When the user click the download result button im getting all the records from a table and store it in the excel file. For this im trying to use COPY command which is in postgre.</p>
  
  <p>My code : </p>
  
  <pre><code>&lt;%@page import="java.sql.ResultSetMetaData"%&gt;
  &lt;%@page import="java.util.ArrayList"%&gt;
  &lt;%@page import="org.apache.poi.hssf.usermodel.HSSFSheet"%&gt;
  &lt;%@page import="org.apache.poi.hssf.usermodel.HSSFCell"%&gt;
  &lt;%@page import="org.apache.poi.hssf.usermodel.HSSFRow"%&gt;
  &lt;%@ page import="java.io.PrintWriter" %&gt;  
  &lt;%@ page contentType="application/excel" language="java" %&gt;  
  
  
  
   &lt;% 
     String fileName = "Result.xls";  
     String strHeader = "attachment;filename=" + fileName; 
     response.setContentType("application/vnd.ms-excel");
  
     PrintWriter op = response.getWriter();  
     PostgresConnection dbCon =  PostgresConnection.getInstance();
     Connection con = dbCon.getConnection();
     Statement st =con.createStatement();
     response.setHeader("Content-disposition",strHeader);
  
  
     st.execute("copy datas.del16 to D:/file.xls DELIMITER ',' CSV HEADER;");        
  
  
    %&gt;
  </code></pre>
  
  <p>In "copy datas.del16 to D:/file.xls DELIMITER ',' CSV HEADER ",       " D:/file.xls" has to be replaced with the path selected by the user.</p>
  
  <p>Thanks,
  Karthika </p>