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

王朝oracle·作者佚名  2008-05-19
窄屏简体版  字體: |||超大  

第二种: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>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航