一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

jsp 文件下载功能代码

时间:2011-10-15 编辑:简简单单 来源:一聚教程网

 代码如下 复制代码
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String SCname=null;
Cookie cookies[]=request.getCookies();
Cookie sCookie=null;
String did = request.getParameter("id");
String qx="0";
String theurl=null;
if (did!=null){
 Statement stmtd=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
 ResultSet Rsd=stmtd.executeQuery("Select * from hl_down where id="+did);
 if(Rsd.next()) {
  theurl=Rsd.getString("url");
  qx=Rsd.getString("qx");
 }
 Rsd.close();
 stmtd.close(); 
 //sCookie=cookies[];
 //out.print(cookies.length);
 //return ;
 if(qx.equals("1")){
  if(cookies!=null){
   if(cookies.length>1){  
    SCname=java.net.URLDecoder.decode(cookies[1].getValue(),"gb2312");
   }
  }
  if (SCname==null){
   response.sendRedirect("login.jsp");
   return ;
  }
 }
 response.sendRedirect(theurl);
 return ;
}

热门栏目