程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> JSP編程 >> 關於JSP >> 用jspsmartupload進行上傳下載

用jspsmartupload進行上傳下載

編輯:關於JSP

這是進行上傳

import java.sql.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.jsp(SUN企業級應用的首選)smart.upload.*;

public class UpLoad extends HttpServlet {

    private ServletConfig config;
    /**
     * Init the servlet
     */
    final public void init(ServletConfig config) throws ServletException {
        this.config = config;
    }

    final public ServletConfig getServletConfig() {
        return config;
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("============UpLoad begin ddd=============");
        String id = null;
        SmartUpload mySmartUpload = new SmartUpload();
        PrintWriter out = response.getWriter();
        java.io.File file=null;
        try {
            Class.forName("Oracle(大型網站數據庫平台).jdbc.driver.Oracle(大型網站數據庫平台)Driver");
        } catch (java.lang.ClassNotFoundException e) {
            System.err.print("ClassNotFoundException: " + e.getMessage());
        }

        try {
            //Class.forName("Oracle(大型網站數據庫平台).jdbc.driver.Oracle(大型網站數據庫平台)Driver");
            Connection conn = DriverManager.getConnection("jdbc:Oracle(大型網站數據庫平台):thin:@10.216.0.2:1521:ORCL", "test", "test");

            conn.setAutoCommit(false); //設置手動提交,以提高性能。
            Statement stmt = conn.createStatement();
            // Initialization
            mySmartUpload.initialize(config, request, response);

            mySmartUpload.setMaxFileSize(500 * 1024);

            // Upload
            mySmartUpload.upload();

            //取得text框中的數據
            id = mySmartUpload.getRequest().getParameter("id");

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved