⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 __softdownaction.java

📁 使用J2EE实现了软件园的下载和上传功能
💻 JAVA
字号:
/* compiled from JSP: /softdownAction.jsp
*
* This code was automatically generated at 18:56:30 on 2007-6-17
* by weblogic.servlet.jsp.Jsp2Java -- do not edit.
*/

package jsp_servlet;

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

// User imports
import java.io.*; //[ /softdownAction.jsp; Line: 2]import java.util.*; //[ /softdownAction.jsp; Line: 2]import javax.naming.*; //[ /softdownAction.jsp; Line: 2]import javax.rmi.*; //[ /softdownAction.jsp; Line: 2]

// built-in init parameters:
// boolean             _verbose -- wants debugging

// Well-known variables:
// JspWriter out                  -- to write to the browser
// HttpServletRequest  request    -- the request object.
// HttpServletResponse response   -- the response object.
// PageContext pageContext        -- the page context for this JSP
// HttpSession session            -- the session object for the client (if any)
// ServletContext application     -- The servlet (application) context
// ServletConfig config           -- The ServletConfig for this JSP
// Object page                    -- the instance of this page's implementation class (i.e., 'this')

/**
* This code was automatically generated at 18:56:30 on 2007-6-17
* by weblogic.servlet.jsp.Jsp2Java -- do not edit.
*
* Copyright (c) 2007 by BEA Systems, Inc. All Rights Reserved.
*/
public final class __softdownaction
extends
weblogic.servlet.jsp.JspBase
implements weblogic.servlet.jsp.StaleIndicator
{
  
  //[ /softdownAction.jsp; Line: 11]  public String codeString(String s){ //[ /softdownAction.jsp; Line: 12]    String str=s; //[ /softdownAction.jsp; Line: 13]    try{ //[ /softdownAction.jsp; Line: 14]      byte b[]=str.getBytes("ISO-8859-1"); //[ /softdownAction.jsp; Line: 15]      str=new String (b); //[ /softdownAction.jsp; Line: 16]      return str; //[ /softdownAction.jsp; Line: 17]    }catch(Exception e){ //[ /softdownAction.jsp; Line: 18]      return "error"; //[ /softdownAction.jsp; Line: 19]    } //[ /softdownAction.jsp; Line: 20]  } //[ /softdownAction.jsp; Line: 21]  //[ /softdownAction.jsp; Line: 22]  // StaleIndicator interface  public boolean _isStale() {    weblogic.servlet.jsp.StaleChecker sci =(weblogic.servlet.jsp.StaleChecker)(getServletConfig().getServletContext());    java.io.File f = null;    long lastModWhenBuilt = 0L;    if (sci.isResourceStale("/softdownAction.jsp", 1181820038000L, "8.1.4.0", "Asia/Shanghai")) return true;    return false;  }    public static boolean _staticIsStale(weblogic.servlet.jsp.StaleChecker sci) {    java.io.File f = null;    long lastModWhenBuilt = 0L;    if (sci.isResourceStale("/softdownAction.jsp", 1181820038000L, "8.1.4.0", "Asia/Shanghai")) return true;    return false;  }      private static void _writeText(ServletResponse rsp, JspWriter out, String block, byte[] blockBytes) throws IOException {    if (!_WL_ENCODED_BYTES_OK || _hasEncodingChanged(rsp)) {      out.print(block);    } else {      ((weblogic.servlet.jsp.ByteWriter)out).write(blockBytes, block);    }   }      private static boolean _hasEncodingChanged(ServletResponse rsp) {    if (_WL_ORIGINAL_ENCODING.equals(rsp.getCharacterEncoding())) {      return false;    }    return true;  }    private static boolean _WL_ENCODED_BYTES_OK = true;    private static final String _WL_ORIGINAL_ENCODING = "GB2312";    private static byte[] _getBytes(String block) {    try {      return block.getBytes(_WL_ORIGINAL_ENCODING);    } catch (java.io.UnsupportedEncodingException u) {      _WL_ENCODED_BYTES_OK = false;    }    return null;  }  private final static String _wl_block0 = "\r\n";  private final static byte[] _wl_block0Bytes = _getBytes(_wl_block0);  private final static String _wl_block1 = "\r\n<html>\r\n<head>\r\n<title>\r\n软件园\r\n</title>\r\n<LINK href=\"css.css\" type=\"text/css\" rel=\"stylesheet\">\r\n</head>\r\n<body bgcolor=\"#ffffff\">\r\n";  private final static byte[] _wl_block1Bytes = _getBytes(_wl_block1);  private final static String _wl_block2 = "\r\n";  private final static byte[] _wl_block2Bytes = _getBytes(_wl_block2);  private final static String _wl_block3 = "\r\n</body>\r\n</html>\r\n\r\n";  private final static byte[] _wl_block3Bytes = _getBytes(_wl_block3);  
  
  public void _jspService(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException 
  {  
    
    // declare and set well-known variables:
    javax.servlet.ServletConfig config = getServletConfig();
    javax.servlet.ServletContext application = config.getServletContext();
    javax.servlet.jsp.tagext.Tag _activeTag = null;
    // variables for Tag extension protocol    
    Object page = this;
    javax.servlet.jsp.JspWriter out;
    javax.servlet.jsp.PageContext pageContext =    javax.servlet.jsp.JspFactory.getDefaultFactory().getPageContext(this, request, response, null, true, 8192, true);    
    response.setHeader("Content-Type", "text/html; charset=GB2312");    out = pageContext.getOut();    JspWriter _originalOut = out;    
    javax.servlet.http.HttpSession session = request.getSession(true);    
    
    
    try { // error page try block            response.setContentType("text/html; charset=GB2312");            _writeText(response, out, _wl_block0, _wl_block0Bytes);      _writeText(response, out, _wl_block1, _wl_block1Bytes);      _writeText(response, out, _wl_block2, _wl_block2Bytes);      //[ /softdownAction.jsp; Line: 23]      String dbPath=request.getParameter("dbPath"); //[ /softdownAction.jsp; Line: 24]      System.out.println(dbPath); //[ /softdownAction.jsp; Line: 25]      String dbID=request.getParameter("dbID"); //[ /softdownAction.jsp; Line: 26]      //System.out.println(dbSoftware); //[ /softdownAction.jsp; Line: 27]      String dbSoftware=dbPath.substring(dbPath.lastIndexOf('\\')+1); //[ /softdownAction.jsp; Line: 28]      System.out.println(dbSoftware); //[ /softdownAction.jsp; Line: 29]      if(dbPath==null) dbPath=""; //[ /softdownAction.jsp; Line: 30]      if(!dbPath.equals("")){ //[ /softdownAction.jsp; Line: 31]        //dbPath=codeString(dbPath); //[ /softdownAction.jsp; Line: 32]        //String dir="E:/Download/"; //[ /softdownAction.jsp; Line: 33]        //dir=dir+dbSoftware; //[ /softdownAction.jsp; Line: 34]        try{    File file=new File(dbPath); //[ /softdownAction.jsp; Line: 35]          if(file.isFile()&&file.exists()){ //[ /softdownAction.jsp; Line: 36]            System.out.print("FileExist"); //[ /softdownAction.jsp; Line: 37]            OutputStream o=response.getOutputStream(); //[ /softdownAction.jsp; Line: 38]            FileInputStream in=new FileInputStream(file); //[ /softdownAction.jsp; Line: 39]            byte b[]=new byte[1024]; //[ /softdownAction.jsp; Line: 40]            dbSoftware=java.net.URLEncoder.encode(dbSoftware,"utf-8");//防止name含有中文的话,输出的文件名称会出现乱码 //[ /softdownAction.jsp; Line: 41]            response.setHeader("Content-disposition","attachment;filename="+dbSoftware); //[ /softdownAction.jsp; Line: 42]            //response.setContentType("application/x-tar");//配合web.xml里面的mime类型定义 //[ /softdownAction.jsp; Line: 43]            long filelength=file.length(); //[ /softdownAction.jsp; Line: 44]            String length=String.valueOf(filelength); //[ /softdownAction.jsp; Line: 45]            response.setHeader("Content_Length",length); //[ /softdownAction.jsp; Line: 46]            int n=0; //[ /softdownAction.jsp; Line: 47]            while((n=in.read(b))!=-1){ //[ /softdownAction.jsp; Line: 48]              o.write(b,0,n); //[ /softdownAction.jsp; Line: 49]            } //[ /softdownAction.jsp; Line: 50]            in.close(); //[ /softdownAction.jsp; Line: 51]            o.close(); //[ /softdownAction.jsp; Line: 52]            out.print("over");; //[ /softdownAction.jsp; Line: 53]          } //[ /softdownAction.jsp; Line: 54]          else{ //[ /softdownAction.jsp; Line: 55]            out.print("文件不存在!"); //[ /softdownAction.jsp; Line: 56]          } //[ /softdownAction.jsp; Line: 57]        } //[ /softdownAction.jsp; Line: 58]        catch(IOException e){ //[ /softdownAction.jsp; Line: 59]          out.print("IOError!"); //[ /softdownAction.jsp; Line: 60]        } //[ /softdownAction.jsp; Line: 61]      } //[ /softdownAction.jsp; Line: 62]      else{ //[ /softdownAction.jsp; Line: 63]        //response.sendRedirect("downloadMain.jsp"); //[ /softdownAction.jsp; Line: 64]        out.print("<script language=JavaScript>alert('没有此软件,请返回');"); //[ /softdownAction.jsp; Line: 65]        out.print("javascript:history.go(-1);</script>"); //[ /softdownAction.jsp; Line: 66]      } //[ /softdownAction.jsp; Line: 67]      try{ //[ /softdownAction.jsp; Line: 68]        Context ic=new InitialContext(); //[ /softdownAction.jsp; Line: 69]        Object obj=ic.lookup("sessionBean"); //[ /softdownAction.jsp; Line: 70]        software.sessionHome home=(software.sessionHome)PortableRemoteObject.narrow(obj,software.sessionHome.class); //[ /softdownAction.jsp; Line: 71]        software.session b=home.create(); //[ /softdownAction.jsp; Line: 72]        b.addDownloadTime(dbID); //[ /softdownAction.jsp; Line: 73]      }catch(Exception ex){ //[ /softdownAction.jsp; Line: 74]        ex.printStackTrace();} //[ /softdownAction.jsp; Line: 75]      //[ /softdownAction.jsp; Line: 76]      //[ /softdownAction.jsp; Line: 76]      _writeText(response, out, _wl_block3, _wl_block3Bytes);    } catch (Throwable __ee) {      while (out != null && out != _originalOut) out = pageContext.popBody();      ((weblogic.servlet.jsp.PageContextImpl)pageContext).handlePageException((Throwable)__ee);    }        
    //before final close brace...
  }
  
  
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -