package yuanyifileup;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.PageContext;public class yuanyifileup
{
private ServletRequest request;
private ServletResponse response;
private ServletConfig config;
ServletInputStream DATA;
int FormSize;
File f1;
FileOutputStream os;
DataInputStream is;
String filename;
byte[] b;
byte t;
boolean flag=false;
public yuanyifileup()
{ }
public void initialize(ServletConfig config,HttpServletRequest request,HttpServletResponse response) throws IOException
{
this.request=request;
this.response=response;
this.config=config;
DATA = request.getInputStream();
FormSize=request.getContentLength();
}
public void initialize(PageContext pageContext) throws IOException
{
request=pageContext.getRequest();
response=pageContext.getResponse();
config=pageContext.getServletConfig();
DATA = request.getInputStream();
FormSize=request.getContentLength();
}
public boolean setFilename(String s)
{
try
{
File f1=new File(s);
os=new FileOutputStream(f1);
}
catch(IOException e)
{return(false);}
return(true);
}
public void getByte()
{
int i=0;
try
{
is=new DataInputStream(DATA);
b=new byte[FormSize];while (true)
{
try
{
t=is.readByte();
b[i]=t;
i++;
}
catch(EOFException e)
{ break;}
}
is.close();}
catch(IOException e)
{}
}public boolean save()
{
int i=0,start1=0,start2=0;
String temp="";
if (!flag)
{
getByte();
flag=true;
}
try
{
temp=new String(b,"ISO8859_1");
}
catch(UnsupportedEncodingException e)
{return(false);}start1=temp.indexOf("image/");
temp=temp.substring(start1);start1=temp.indexOf("\r\n\r\n");temp=temp.substring(start1+4);
start2=temp.indexOf(";\r\n");
if (start2!=-1)
{
temp=temp.substring(0,start2);
}
try
{
byte[] img=temp.getBytes("ISO8859_1");
for (i=0;i<img.length;i++)
{ os.write(img[i]); }
os.close();
}
catch(IOException e)
{return(false);}return(true);}
}
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.PageContext;public class yuanyifileup
{
private ServletRequest request;
private ServletResponse response;
private ServletConfig config;
ServletInputStream DATA;
int FormSize;
File f1;
FileOutputStream os;
DataInputStream is;
String filename;
byte[] b;
byte t;
boolean flag=false;
public yuanyifileup()
{ }
public void initialize(ServletConfig config,HttpServletRequest request,HttpServletResponse response) throws IOException
{
this.request=request;
this.response=response;
this.config=config;
DATA = request.getInputStream();
FormSize=request.getContentLength();
}
public void initialize(PageContext pageContext) throws IOException
{
request=pageContext.getRequest();
response=pageContext.getResponse();
config=pageContext.getServletConfig();
DATA = request.getInputStream();
FormSize=request.getContentLength();
}
public boolean setFilename(String s)
{
try
{
File f1=new File(s);
os=new FileOutputStream(f1);
}
catch(IOException e)
{return(false);}
return(true);
}
public void getByte()
{
int i=0;
try
{
is=new DataInputStream(DATA);
b=new byte[FormSize];while (true)
{
try
{
t=is.readByte();
b[i]=t;
i++;
}
catch(EOFException e)
{ break;}
}
is.close();}
catch(IOException e)
{}
}public boolean save()
{
int i=0,start1=0,start2=0;
String temp="";
if (!flag)
{
getByte();
flag=true;
}
try
{
temp=new String(b,"ISO8859_1");
}
catch(UnsupportedEncodingException e)
{return(false);}start1=temp.indexOf("image/");
temp=temp.substring(start1);start1=temp.indexOf("\r\n\r\n");temp=temp.substring(start1+4);
start2=temp.indexOf(";\r\n");
if (start2!=-1)
{
temp=temp.substring(0,start2);
}
try
{
byte[] img=temp.getBytes("ISO8859_1");
for (i=0;i<img.length;i++)
{ os.write(img[i]); }
os.close();
}
catch(IOException e)
{return(false);}return(true);}
}
解决方案 »
- 见鬼了,这个hibernateTemplate
- webservice发布问题
- 这到底是什么问题啊!!!!
- 跪求一个EJB开发例子
- 高分请教lucene与hibernate集成问题
- 我的验证码图片在TOMCAT下面能正常显示出来,为什么在weblogic8.1下面就显示不出来呢,高手帮忙啊!郁闷啊!!!!!!!!!!!!!!
- 怎么让数据库插入数据的时候能够插入一个单引号的一半
- Tomcat下JSP、Servlet和JavaBean环境的配置问题
- 牛人出手相助把,生成xml问题
- 本人已經寫好了一個BEAN管理的實體BEAN,但不知怎樣在WEBLOGIC中配置(每次部署都出錯,可能是數據庫部分沒有配好)?????
- 如何调用动态的 下载? 我要 JSPSmartUpload做的调用某个文件夹下最新的10个文件,做成下载的连接!
- OpenCRX都实现了什么?
http://dev2dev.bea.com.cn/bbs/thread.jspa?forumID=121&threadID=29766&tstart=0
http://dev2dev.bea.com.cn/bbs/thread.jspa?forumID=121&threadID=29766&tstart=0
http://blog.csdn.net/jyy7751/archive/2005/06/17/396495.aspx
<%@ page contentType="text/html; charset=gb2312" language="java"
import="com.jspsmart.upload.*,java.util.*" %>
<html>
<head>
<title>文件上传处理页面</title>
<style type="text/css"> </style> <link href="../../css/css.css" rel="stylesheet" type="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body>
<%
//com.jspsmart.upload.File file_down = su.getFiles().getFile(0);
//String file_down_name=file_down.getFileName(); // 下载文件
//su.downloadFile("D:/ZXDATA/SEND/");
//把SEND目录下的所有文件名(截取日期的8位)放入数组,以备排序
/* **********************************************************
//JSP那个函数可以读取某个文件夹下的所有文件名?
//并且返回这个文件夹下的文件个数,以备For循环调用时用
int[] send_file_name_sort = new int[su.getFiles().getCount()];
for (int i = 0; i < su.getFiles().getCount(); i++) {
com.jspsmart.upload.File file_down = su.getFiles().getFile(0);
if (file_down.isMissing()) continue;
String file_date_msg = file_down.getFileName().substring(5, 12);
int file_date_int = Integer.parseInt(file_date_msg);
send_file_name_sort[i] = file_date_int;
}
************************************************************** */ //******************把所有文件排序!***************************
int[] send_file_name_sort = new int[];
String[] send_file_name_10 = new String[10];
out.println("<BR>" + "-------------原来SEND文件夹中的所有CMIS压缩报文-------------" + "<BR>");
send_file_name_sort[0] = 20051201;
for (int i = 0; i < send_file_name_sort.length; i++) {
send_file_name_sort[i] = send_file_name_sort[0] + i; out.println((i + 1) + ":" + "\t\t\t" + "send" + send_file_name_sort[i] + ".zip" + "<BR>");
}
Arrays.sort(send_file_name_sort); //从小到大排序(日期从较早到现在) ,排在后面的日期越新
out.println("<BR>" + "-------------你可以下载的10个最新CMIS报文压缩文件-------------" + "<BR>");
//*************************只截取最新的十个文件*******************
for (int i = 1; i < 11; i++) {
out.println("你可以下载的CMIS报文压缩文件" + i + ":" + "<a href=" + "\"" + "../page/do_download_sample" + (i-1) + ".jsp" + "\">" + "send" + send_file_name_sort[send_file_name_sort.length - i] + ".zip" + "</a> "); send_file_name_10[i-1] = "send" + send_file_name_sort[i-1] + ".zip"; out.println("<BR>");
}
%>
<div align="center"><a href="../page/down_load_sample.html">返回</a></div></body>
</html>
------------------------------------------------- do_download_sample0.jsp-----------------------
<%@ page contentType="text/html;charset=gb2312"
import="com.jspsmart.upload.*" %><%
// 新建一个SmartUpload对象
SmartUpload su = new SmartUpload();
// 初始化
su.initialize(pageContext);
// 设定contentDisposition为null以禁止浏览器自动打开文件,
//保证点击链接后是下载文件。若不设定,则下载的文件扩展名为
//doc时,浏览器将自动用word打开它。扩展名为pdf时,
//浏览器将用acrobat打开。
su.setContentDisposition(null);
// 下载文件//****************这里的send_file_name_10[0]提示无法识别改变量*************su.downloadFile("D:/ZXDATA/SEND/"+send_file_name_10[0]);//问题的关键就在这里!如何读取display_10.jsp 文件中的send_file_name_10数组 %>
/**********后面的send_file_name_10[1]~ send_file_name_10[9]都是这个问题!**********
*****************提示无法识别改变量************
********************************问题的关键就在这里!*************************
******如何读取display_10.jsp 文件中的send_file_name_10数组***************/