這是進行上傳
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");