<%@ page language="java" contentType="text/html;charset=UTF-8"%> <%@page import="java.io.*,com.csc.library.entry.HelpEntry,com.csc.library.system.*,com.csc.library.utilities.*"%> <%@ page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*" %> <% String file = (String)request.getParameter("__File"); //response.setContentType("application/vnd.ms-excel"); //response.setHeader("Content-disposition","inline;attachment;filename=http://192.100.1.2:8082/hr/WELFARE/REPORT/666.xls"); String filePath="D:/EnterprisePT/Jboss4/server/default/deploy/HRPEAP.ear/hrAppWeb.war/666.xls"; // response.setContentType("application/x-msdownload"); // or response.setContentType("application/unknown"); response.addHeader("Content-Disposition", "attachment; filename=666.xls"); try{ File uFile= new File(filePath); int fSize=(int)uFile.length(); FileInputStream fis = new FileInputStream(uFile); PrintWriter pw = response.getWriter(); int c=-1; // Loop to read and write bytes. //pw.print("Test"); while ((c = fis.read()) != -1){ pw.print((char)c); } // Close output and input resources. fis.close(); pw.flush(); pw=null; }catch(Exception e){ e.printStackTrace(); } %>