http://www.jspsmart.com/
下载组件,
里面有现成的例子.

解决方案 »

  1.   

    这是数据库操作页面<%@page contentType="text/html"%>
    <%@page import="java.io.*"%>
    <%@page import="java.sql.*"%>
    <html>
    <head><title>JSP Page</title></head>
    <body><%Class.forName("org.gjt.mm.mysql.Driver").newInstance(); 
    String url ="jdbc:mysql://localhost/graduate"; 
    Connection conn= DriverManager.getConnection(url,"root",""); //connect db
    String fileName = request.getParameter("file");
    FileInputStream is = new FileInputStream(fileName);
    int ch;
    while ((ch = is.read()) >= 0)
      out.print((char) ch);
    //get file stream
    String sql="insert into upload (ID,file) values(1,?)";PreparedStatement pstmt=conn.prepareStatement(sql); 
    pstmt.setBinaryStream(1,is,is.available());
    pstmt.execute();
    out.println("Success,You Have Insert an Image Successfully");
    is.close();
    %> </body>
    </html>这是接受文件页面
    <%@page contentType="text/html"%>
    <html>
    <head><title>JSP Page</title></head>
    <body><form action="/up" method="POST" >
    <input type="file" name="file"><br>
    <input type="submit">
    </form></body>
    </html>
      

  2.   

    http://www.jspsmart.com/
    呵呵,下载后,看它的例子代码啊。