Oracle中三種上載文件技術(二)
2024-08-29 13:41:32
供稿:網(wǎng)友
第二種:Oracle 9iAS的標簽庫和Bean提供的文件上載功能
Oracle developer suit 9i 中的Jdeveloper9031提供通過標簽庫上載文件的方法,下面的例子中in_file.jsp文件提供上載表單,up_file.jsp列出上載文件列表,dn_file.jsp文件為下載剛才上載的文件。該方法使用圖形編輯器,簡單可行,但不支持中文文件名,可實現(xiàn)客戶端文件上載和下載。
如下為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 >下載!</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>