title: excel can not open the downloaded file through jsp
body: <p>this is the code for download excel file on browser but when i open it excel throw a error "Excel can not open the file 'Location.xlsx' because the file format or file extension is not valid. verify that the file has not been corrupted and that the file extension matches the format of the file" but when i simply create this file its opening only this error is coming when i perform download operation and i am using poi jar for excel file creation...???</p>
  
  <pre><code>&lt;html&gt;
  
      &lt;body&gt;
          &lt;%
     LocationDownload.downloadLocation();
  %&gt;
  &lt;% 
    String filename = "Location.xlsx";   
    String filepath = "C:\\Users\\dsingh\\GlassFish_Server\\glassfish\\domains\\domain1\\config\\";   
    response.setContentType("application/vnd.ms-excel");   
    response.setHeader("Content-Disposition","attachment; filename=" + filename);   
  
    java.io.FileInputStream fileInputStream=new java.io.FileInputStream(filepath + filename);  
  
    int i;   
    while ((i=fileInputStream.read()) != -1) {  
      out.write(i);   
     }   
    fileInputStream.close();   
  %&gt;   
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>