当前位置:编程学习 > JS >>

用jspsmartupload进行上传下载

这是进行上传

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");

补充:Web开发 , Jsp ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,