title: How to open the Excel File in without prompt & not inside browser using Servlet?
body: <p>I have writen the Java code to send the excel to client side. I am calling servlet from java script when the user click on the button in the page. But the File is opening in the same browser. Instead how to open the file in excel format not inside the browser without save/close dialog?</p>
  
  <p>Java Script While clicking on one button</p>
  
  <pre><code> window.location = url+'?Data='+Math.random();
  </code></pre>
  
  <p>Java</p>
  
  <pre><code>String ramdonNumber =this.getHttpRequest().getParameter("Data");
          System.out.println("Inside Action"+ramdonNumber);
          File file = new File("C:/Documents and Settings/XXXXXX/Desktop/RevisedAvailableSeatForSRESR.xls");
  
          try {
              this.setFileInputStream(new FileInputStream(file));
          } catch (FileNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
          HttpServletResponse response = this.getHttpResponse();
          response.setHeader("Content-Type", "application/vnd.ms-excel");
          response.setHeader("Content-Disposition",
                  "inline;filename=\"" + file.getName() + ".xls\";");
  </code></pre>