java用servlet实现文件上传到数据库
2009-03-19 14:26
index.jsp
文件上传
web.xml
upload
servletUpload
upload
/servletUpload
index.jsp
lib:jspupload.jar
java:
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.jspsmart.upload.*;
public class servletUpload extends HttpServlet {
private ServletConfig config;
/**
* 初始化Servlet
*/
final public void init(ServletConfig config) throws ServletException {
this.config = config;
}
/**
* 处理GET请求
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println("jspSmartUpload : Servlet Sample");
out.println("");
out.println("The method of the HTML form must be POST.");
out.println("");
out.println("");
}
/**
* 响应POST请求
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("");
out.pr
1