SAMLE4上传的代码  
<%@  page  language="java"  import="java.sql.*,com.jspsmart.upload.*"%>  
<jsp:useBean  id="mySmartUpload"  scope="page"  class="com.jspsmart.upload.SmartUpload"  />  
 
<HTML>  
<BODY  BGCOLOR="white">  
 
<H1>jspSmartUpload  :  Sample  4</H1>  
<HR>  
 
<%  
           //  Variables  
           int  count=0;  
 
           //  Connect  to  the  database  
           Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();  
           Connection  con  =  DriverManager.getConnection("jdbc:microsoft:sqlserver://server:1433;DatabaseName=test","sa","");  
 
//  SQL  Requestconn=DriverManager.getConnection(sconnstr,"sa","");  
Statement  stmt  =  con.createStatement(ResultSet.TYPE_FORWARD_ONLY  ,ResultSet.CONCUR_UPDATABLE);  
ResultSet  rs  =  stmt.executeQuery("SELECT  *  FROM  TFILES  WHERE  ID=3");  
           if  (rs.next()){  
 
                       //  Initialization  
                       mySmartUpload.initialize(pageContext);  
mySmartUpload.setMaxFileSize(500  *  1024);  
                       //  Upload  
                       mySmartUpload.upload();  
 
           //  upload  file  in  the  DB  if  this  file  is  not  missing  
           if  (!mySmartUpload.getFiles().getFile(0).isMissing()){  
 
                                   try  {  
 
                                               rs.updateString("FILENAME",mySmartUpload.getFiles().getFile(0).getFileName());  
                                                 
                       //  Add  the  current  file  in  the  DB  field  
mySmartUpload.getFiles().getFile(0).fileToField(rs,"FILE");  
 
                                               //  Update  
                                               rs.updateRow();  
                                               count++;                          
                                                 
                                   }  catch(Exception  e)  {  
                                               out.println("An  error  occurs  :  "  +  e.toString());                                                  
                                   }                                      
 
                       }  
 
           }  
 
           //  Display  the  number  of  files  uploaded  
           out.println(count  +  "  file(s)  uploaded  in  the  database.");  
 
           rs.close();  
           stmt.close();  
           con.close();  
 
           %>  
</BODY></HTML>  
 
下载的代码,原来的sample7,经过改装  
 
<%@  page  language="java"  import="java.sql.*,com.jspsmart.upload.*"%><jsp:useBean  id="mySmartUpload"  scope="page"  class="com.jspsmart.upload.SmartUpload"  /><%  
 
 
           //  Connect  to  the  database  
           Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();  
           Connection  con  =  DriverManager.getConnection("jdbc:microsoft:sqlserver://server:1433;DatabaseName=test","sa","");  
 
           //  SQL  Request  
           Statement  stmt  =  con.createStatement();  
ResultSet  rs  =  stmt.executeQuery("SELECT  *  FROM  TFILES  where  id=3");  
 
           //  if  the  resultset  is  not  null  
           if  (rs.next()){  
                       String  FileName=rs.getString("FileName");  
                       //  Initialization  
mySmartUpload.initialize(pageContext);  
mySmartUpload.setTotalMaxFileSize(200000);                
           //  Download  field  
mySmartUpload.downloadField(rs,"FILE","application/x-msdownload",  "2.txt");  
 
//  mySmartUpload.fieldToFile(rs,"FILE","c:\\temp\\sample7.txt");  
 
           }  
 
           rs.close();  
           stmt.close();  
           con.close();  
 
%>