当前位置导航:炫浪网>>网络学院>>编程开发>>Oracle教程

Oracle中三种上载文件技术(二)


  第二种:Oracle 9iAS的标签库和Bean提供的文件上载功能
    Oracle developer suit 9i 中的Jdeveloper9031提供通过标签库上载文件的方法,下面的例子中in_file.jsp文件提供上载表单,up_file.jsp列出上载文件列表,dn_file.jsp文件为下载刚才上载的文件。该方法使用图形编辑器,简单可行,但不支持中文文件名,可实现客户端文件上载和下载。
  
    如下为in_file.jsp的源程序:
  
  <%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/fileaccess.tld"
  prefix="fileaccess" %>
  <%@ page language="java" import="java.io.*" contentType="text/html" %>
  <html>
  <head>
  <meta http-equiv="Content-Type" content="text/HTML;charset=gb2312">
  <title>jdbc upload and download blob</title>
  </head>
  <body>
  <fileaccess:httpUploadForm
  formsAction="up_file.jsp"
  maxFiles="5" fileNameSize="100"
  maxFileNameSize="150" submitButtonText="send">
  </fileaccess:httpUploadForm>
  </body> </html>
  
    up_file.jsp的源程序:
  
  <%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/sqltaglib.tld" prefix="database" %>
  <%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/fileaccess.tld" prefix="fileaccess" %>
  <%@ page language="java" contentType="text/html; charset=gb2312"%>
  <html>
  <head>
  <meta http-equiv="Content-Type" content="text/HTML;charset=gb2312">
  <title>jdbc upload and download blob</title>
  </head>
  <body>
  <database:dbOpen user="zy" password="zy"
  URL="jdbc:oracle:thin:@db92:1521:cf92" commitOnClose="true">
  <fileaccess:httpUpload
  destination="zy_blob"
  destinationType="database"
  table="blob_table">
  </fileaccess:httpUpload>
  </database:dbOpen>
  Done!
  <a href="dn_file.jsp">下载!</a>
  </body></html>
  
    dn_file.jsp的源程序:
  
  <%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/fileaccess.tld" prefix="fileaccess" %>
  <%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/sqltaglib.tld" prefix="database" %>
  <%@ page contentType="text/html;charset=GBK"%>
  <html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=GBK">
  </head>
  <body>
  <database:dbOpen user="zy" password="zy"
  URL="jdbc:oracle:thin:@db92:1521:cf92">
  <fileaccess:httpDownload source="*" servletPath="/"
  sourceType="database" table="blob_table">
  </fileaccess:httpDownload>
  </database:dbOpen>
  Download done!
  </body>
  </html>
相关内容
赞助商链接