<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.io.*,java.text.*,java.util.*,java.sql.*,javax.servlet.http.*"%>
<%@ page import = "zr.zrpower.entity.sys.SessionUser" %>
<%@ page import = "zr.zrpower.ejb.sys.UIService" %>
<%@ page import = "zr.zrpower.ejb.sys.SeManageService" %>

<%@ page import = "java.lang.Object"%>
<HTML>
<%
SessionUser user = (SessionUser)session.getAttribute("userinfo");
UIService userUI =new UIService();
SeManageService SeService =new SeManageService();
%>
<HTML>
<HEAD>
<TITLE></TITLE>
<META http-equiv="Content-Type" content="text/html; charset=GBK">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<link REL="stylesheet" type="text/css" href="../css/<%=user.getUserCSS()%>">
<%
  int len=0;
  String strID = request.getParameter("ID");
  //得到服务器上的完整路径
  String strAllPath = SeService.SysAttFileAllPath(strID);
  //得到服务器上的文件名
  String fileName = SeService.GetSysAttFileName(strID);
  //读到流中

  java.io.File fl=new File(strAllPath);
  if(fl.exists()){
  InputStream inStream=new FileInputStream(strAllPath);
  //设置输出的格式
  response.reset();
  response.setContentType("bin");
  response.addHeader("Content-Disposition","attachment; filename=\"" +new String(fileName.getBytes("gb2312"),"iso8859-1") +  "\"");

  //循环取出流中的数据


  byte[] b = new byte[100];
  try
  {
    ServletOutputStream OutBinarry=response.getOutputStream() ;
    while ((len=inStream.read(b))>0)
    {
      OutBinarry.write(b,0,len);
      OutBinarry.flush();
    }
    OutBinarry.close();
    inStream.close();
    OutBinarry =null;
    inStream = null;
    //_jspxFactory = null;
  }catch(Exception e)
  {
    System.out.println(e.toString());
  }
  }else{
%>
<SCRIPT LANGUAGE="JavaScript">
  alert("该文件不存在");
  history.back();
</SCRIPT>
<%
  }
%>
</HEAD>
</HTML>
<%
//清空相关对象
user = null;
userUI = null;
SeService = null;
%>
