是的,JspSmart只能上传到服务器,如果需要传到数据中,还是自己动手写吧
解决方案 »
- 急求!关于JSP项目的图片存储和读取的问题?
- zhuchao_ko : 关于Protal、SOA(抛砖引玉)
- struts2一旦使用constants就报错404
- 如何封装session失效异常。大家进来看看。
- mysql插入10000条数据时出错,在线等.......
- catch错误后,应该怎样处理?
- 一个关于Struts Action的小框架, 请高手指点一下
- servlet 发送邮件问题 急
- 用APPLET读取SERVER端的数据,并画图的问题
- spring中的HibernateTemplate与OpenSessionInViewFilter 的session管理机制问题
- JSP/BEAN/SERVLET 哪一种方式效率更高一点呢?
- 我用servlet來打開一個excel文件,但為何只讓我下載呀,請教啦各位,源碼如下:
import com.landmis.storage.DBOperation;
import com.landmis.util.LandProperty;
import java.io.File;
import java.io.PrintStream;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;public class ArchiveFileProxyBean
{ public ArchiveFileProxyBean()
{
docmentId = 0;
} public int getDocmentId()
{
return docmentId;
} public int saveArchiveFile(ArchiveFileBean archivefilebean)
{
int i = 0;
int j = 0;
String s = "";
String s1 = "";
String s2 = "";
java.util.Date date = null;
int k = 0;
String s3 = "";
String s4 = "";
String s5 = "";
String s6 = "";
int l = 0;
i = archivefilebean.getArchiveId();
j = archivefilebean.getFileId();
s = archivefilebean.getDocId();
s1 = archivefilebean.getDutier();
s2 = archivefilebean.getFileName();
date = archivefilebean.getInputFileDate();
k = archivefilebean.getDocPageNumber();
s3 = archivefilebean.getLimitDate();
s4 = archivefilebean.getDocWhere();
s6 = archivefilebean.getRe();
DBOperation dboperation = null;
try
{
try
{
dboperation = new DBOperation();
docmentId = DBOperation.getSequenceId("S_ARCHIVE_FILE");
String s7 = "insert into archive_file values(" + docmentId + "," + i + "," + j + ",'" + s + "','" + s1 + "','" + s2 + "',TO_DATE('" + new Date(date.getTime()) + "','YYYY-MM-DD')," + k + ",'" + s3 + "','" + s4 + "','" + s5 + "','" + s6 + "'," + l + ")";
int i1 = dboperation.executeUpdate(s7);
int j1 = i1;
return j1;
}
catch(SQLException sqlexception)
{
System.err.println(sqlexception);
sqlexception.printStackTrace();
}
}
finally
{
dboperation.closeConnection();
}
return 0;
} public int updateArchiveFile(ArchiveFileBean archivefilebean)
{
int i = 0;
int j = 0;
int k = 0;
String s = "";
String s1 = "";
String s2 = "";
java.util.Date date = null;
int l = 0;
String s3 = "";
String s4 = "";
String s5 = "";
i = archivefilebean.getDocmentId();
j = archivefilebean.getArchiveId();
k = archivefilebean.getFileId();
s = archivefilebean.getDocId();
s1 = archivefilebean.getDutier();
s2 = archivefilebean.getFileName();
date = archivefilebean.getInputFileDate();
l = archivefilebean.getDocPageNumber();
s3 = archivefilebean.getLimitDate();
s4 = archivefilebean.getDocWhere();
s5 = archivefilebean.getRe();
DBOperation dboperation = null;
try
{
try
{
dboperation = new DBOperation();
String s6 = " update archive_file set FILE_ID=" + k + ",DOC_ID='" + s + "',DUTIER='" + s1 + "',FILE_NAME='" + s2 + "',FILE_DATE=TO_DATE('" + new Date(date.getTime()) + "','YYYY-MM-DD')" + ",DOC_PAGE_NUMBER=" + l + ",LIMIT_DATE='" + s3 + "',DOC_WHERE='" + s4 + "',REMARK='" + s5 + "' where DOCMENT_ID=" + i;
System.out.println("sqlstate = " + s6);
int i1 = dboperation.executeUpdate(s6);
int j1 = i1;
return j1;
}
catch(SQLException sqlexception)
{
System.err.println(sqlexception);
sqlexception.printStackTrace();
}
}
finally
{
dboperation.closeConnection();
}
return 0;
} public int deleteArchiveFile(ArchiveFileBean archivefilebean)
{
int i = -1;
String s = "Y";
i = archivefilebean.getDocmentId();
System.out.println("success .........");
System.out.println("DELMARK = " + s);
try
{
DBOperation dboperation = new DBOperation();
String s1 = " update archive_file set DELMARK= '" + s + "' where DOCMENT_ID=" + 1;
System.out.println("sqlstate = " + s1);
int j = dboperation.executeUpdate(s1);
return j;
}
catch(SQLException sqlexception)
{
System.err.println(sqlexception);
sqlexception.printStackTrace();
return 0;
}
} public String getFilePath(int i)
{
String s;
label0:
{
ResultSet resultset = null;
DBOperation dboperation = null;
int j = 0;
s = null;
try
{
try
{
try
{
dboperation = new DBOperation();
String s1 = "select archives_id from archives_info where archives_id = " + i;
resultset = dboperation.executeQuery(s1);
if(resultset.next())
j = resultset.getInt(1);
LandProperty landproperty = new LandProperty();
String s2 = landproperty.getProperty("BASIC_PATH");
s = "files/archive/archive_" + j;
File file = new File(s2 + s);
file.mkdirs();
System.out.print("created " + file);
}
catch(SQLException sqlexception)
{
System.err.println(sqlexception);
sqlexception.printStackTrace();
}
break label0;
}
finally
{
resultset.close();
dboperation.closeConnection();
}
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
return s;
} private int docmentId;
}
引用<%@ include file="../../head.jsp"%>
<%@ page import="com.landmis.storage.upload.*,
com.landmis.archiveMGMT.module.ArchiveFileProxyBean"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.landmis.storage.upload.SmartUpload" />
<HTML><title>success</title>
<link rel="stylesheet" href="../../css/dangan.css" type="text/css">
<link rel="stylesheet" href="../../css/line.css" type="text/css">
<BODY BGCOLOR="#99FFCC" topmargin="40">
<% int archiveId = PublicInfoBean.getArchiveId();
int docmentId = PublicInfoBean.getDocmentId();
// Variables
int count=0; // Initialization
mySmartUpload.initialize(pageContext); mySmartUpload.setTotalMaxFileSize(100000); // Upload
mySmartUpload.upload();
ArchiveFileProxyBean afp = new ArchiveFileProxyBean();
String filePath = afp.getFilePath(archiveId); try { // Save the files with their original names in the virtual path "/upload"
// if it doesn't exist try to save in the physical path "/upload"
count = mySmartUpload.save(filePath);
// Save the files with their original names in the virtual path "/upload"
// count = mySmartUpload.save("/archive", mySmartUpload.SAVE_VIRTUAL); // Display the number of files uploaded
int i = mySmartUpload.saveFileName(docmentId); } catch (Exception e) {
out.println(e.toString());
}
%>
<br>
<br>
<br>
<br>
<table width="65%" border="0" cellspacing="0" cellpadding="0" align="center" height="120">
<tr>
<td>
<div align="center"><img src="../images/success.jpg" width="490" height="101" border="0" usemap="#Map"></div>
</td>
</tr>
</table>
<map name="Map">
<area shape="rect" coords="441,77,474,96" href="file_list.jsp">
</map>
</BODY>
</HTML>