K
kerwin
Unregistered / Unconfirmed
GUEST, unregistred user!
各位大虾,小弟这段代码在weblogic7下运行的时候内存稳步上升,请帮忙看看哪里有问题?public voiddo
Get(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String rst,StrFile,SrcBuf,StrPath,filter,OpeType;
FilenameFilter filefilter;
byte[] size=new byte[0];
response.setContentType(CONTENT_TYPE);
ServletPath=request.getServletPath();
rst="";
try{
if ("GetFileList".equals(request.getParameter("OpeType"))){
if (request.getParameter("Nsr") .equals("") ){
throw new ServletException("未指定纳税人");
};
if (request.getParameter("Nsr").length() >15){//附加9位分局代码
StrPath=ServletPath+"/"+request.getParameter("Nsr").substring(16,25)+"/rn/";
} else
{
StrPath=ServletPath+"/rn/";
};
//判断目录是否存在
File f1=new File(StrPath);
if(!f1.exists() ){
f1.mkdirs();
};
//开始查找文件
filefilter=new FilefilterClass("RZ00101",request.getParameter("Nsr").substring(0,15),".dat");
String Filename[]=f1.list(filefilter);
rst="";
for (int i=0;i<Filename.length ;i++) {
rst=rst+Filename+"/n";
}
if (rst.equals("") ){
//抛出异常
throw new ServletException("未找到回执文件");
}else
{
size=rst.getBytes();
}
}else
if ("SvrGetFileList".equals(request.getParameter("OpeType") )){
if (request.getParameter("FJDM") .equals("") ){
filefilter=new FilefilterClass("RZ00100","",".dat");
StrPath=ServletPath+"/";
}else
{
filefilter=new FilefilterClass("RZ00100","",request.getParameter("FJDM").toString()+".dat");
StrPath=ServletPath+"/"+request.getParameter("FJDM").toString() +"/";
}
//开始查找文件
File f2=new File(StrPath);
if(!f2.exists()){
throw new ServletException("未找到文件"+StrPath);
}
String Filename2[]=f2.list(filefilter);
rst="";
for (int i=0;i<Filename2.length ;i++) {
rst=rst+Filename2+"/n";
if (i>1024){break;}
}
if (rst.equals("") ){
//抛出异常
throw new ServletException("未找到文件");
}else
{
size=rst.getBytes();
}
}
else
if ("SvrGetDirList".equals(request.getParameter("OpeType"))){
File f3=new File(ServletPath+"/");
//filefilter=new FilefilterClass("RZ00101",request.getParameter("Nsr").substring(0,15),".dat");
//String DirName[]=f3.list(filefilter);
String DirName[]=f3.list();
rst="";
for (int i=0;i<DirName.length ;i++) {
File Strdir=new File(ServletPath+"/"+DirName);
if(Strdir.isDirectory() ){
if(DirName.length() ==9){
rst = rst + DirName + "/n";
}
}
}
if (rst.equals("") ){
//抛出异常
throw new ServletException("未找到文件");
}else
{
size=rst.getBytes();
}
}else
if ("GetFile".equals(request.getParameter("OpeType"))){
FileInputStream SrcF=null;
StrFile=request.getParameter("File") ;
if (StrFile.equals("")) {
//抛出异常
throw new ServletException("未指定文件名");
}
if (!StrFile.toUpperCase() .substring(0,7) .equals("RZ00101") ){
//抛出异常
throw new ServletException("文件名不合法");
}
if (StrFile.length() >40){
StrPath=ServletPath+"/"+StrFile.substring(36,45)+"/"+"rn/";
}else
{
StrPath=ServletPath+"/rn/";
}
//判断目录是否存在
File f3=new File(StrPath);
if(!f3.exists() ){
f3.mkdirs();
};
StrFile=StrPath+StrFile;
File f4=new File(StrFile);
if (!f4.exists() ){
//抛出异常
throw new ServletException("未找到文件:"+StrFile);
}
try{
try{
SrcF = new FileInputStream(f4);
}
catch (Throwable e) {
Thread.currentThread().sleep(3000);
SrcF = new FileInputStream(f4);
}
int filesize=(int)f4.length() ;
size=new byte[filesize];
SrcF.read(size) ;
}
finally {
SrcF.close();
}
}
else
if ("SvrGetFile".equals(request.getParameter("OpeType"))){
FileInputStream SrcF=null;
StrFile=request.getParameter("File") ;
if (StrFile.equals("")) {
//抛出异常
throw new ServletException("未指定文件名");
}
if (!StrFile.toUpperCase() .substring(0,7) .equals("RZ00100") ){
//抛出异常
throw new ServletException("文件名不合法");
}
if (StrFile.length() >40){
StrPath=ServletPath+"/"+StrFile.substring(36,45)+"/";
}else
{
StrPath=ServletPath+"/";
}
//判断目录是否存在
File f3=new File(StrPath);
if(!f3.exists() ){
f3.mkdirs();
};
StrFile=StrPath+StrFile;
File f4=new File(StrFile);
if (!f4.exists() ){
//抛出异常
throw new ServletException("未找到文件:"+StrFile);
}
try{
try{
SrcF=new FileInputStream(StrFile);
}
catch(Exception e){
Thread.currentThread().sleep(3000);
SrcF=new FileInputStream(StrFile);
}
int filesize=(int)f4.length() ;
size=new byte[filesize];
SrcF.read(size) ;
}
finally {
SrcF.close();
}
}
else
if ("DeleteFile".equals(request.getParameter("OpeType"))){
StrFile=request.getParameter("File") ;
if (StrFile.equals("")) {
//抛出异常
throw new ServletException("未指定文件名");
}
if (!StrFile.toUpperCase() .substring(0,7) .equals("RZ00101") ){
//抛出异常
throw new ServletException("文件名不合法");
}
if (StrFile.length() >40){
StrPath=ServletPath+"/"+StrFile.substring(36,45)+"/"+"rn/";
}else
{
StrPath=ServletPath+"/rn/";
}
//判断目录是否存在
File f3=new File(StrPath);
if(!f3.exists() ){
f3.mkdirs();
};
StrFile=StrPath+StrFile;
File f4=new File(StrFile);
if (!f4.exists() ){
//抛出异常
throw new ServletException("未找到文件");
}
if (f4.delete() ){
rst="OK!";
size=rst.getBytes();
}else
{
//抛出异常
throw new ServletException("无法删除文件,文件已不存在或可能在使用:"+StrFile);
}
}
else
if ("SvrDeleteFile".equals(request.getParameter("OpeType"))){
StrFile=request.getParameter("File") ;
if (StrFile.equals("")) {
//抛出异常
throw new ServletException("未指定文件名");
}
if (!StrFile.toUpperCase() .substring(0,7) .equals("RZ00100") ){
//抛出异常
throw new ServletException("文件名不合法");
}
if (StrFile.length() >40){
StrPath=ServletPath+"/"+StrFile.substring(36,45)+"/";
}else
{
StrPath=ServletPath+"/";
}
//判断目录是否存在
File f3=new File(StrPath);
if(!f3.exists() ){
f3.mkdirs();
};
StrFile=StrPath+StrFile;
File f4=new File(StrFile);
if (!f4.exists() ){
//抛出异常
throw new ServletException("未找到文件");
}
if (f4.delete() ){
rst="OK!";
size=rst.getBytes();
}else
{
//抛出异常
throw new ServletException("无法删除文件,文件已不存在或可能在使用:"+StrFile);
}
}
if (size.length==0){
throw new ServletException("URL不合法");
}
}
catch(Throwable e) {
rst="Err"+e.getMessage() ;
size=rst.getBytes();
}
finally{
ServletOutputStream out=response.getOutputStream();
//out.print(rst) ;
out.write(size);
}
}
Get(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String rst,StrFile,SrcBuf,StrPath,filter,OpeType;
FilenameFilter filefilter;
byte[] size=new byte[0];
response.setContentType(CONTENT_TYPE);
ServletPath=request.getServletPath();
rst="";
try{
if ("GetFileList".equals(request.getParameter("OpeType"))){
if (request.getParameter("Nsr") .equals("") ){
throw new ServletException("未指定纳税人");
};
if (request.getParameter("Nsr").length() >15){//附加9位分局代码
StrPath=ServletPath+"/"+request.getParameter("Nsr").substring(16,25)+"/rn/";
} else
{
StrPath=ServletPath+"/rn/";
};
//判断目录是否存在
File f1=new File(StrPath);
if(!f1.exists() ){
f1.mkdirs();
};
//开始查找文件
filefilter=new FilefilterClass("RZ00101",request.getParameter("Nsr").substring(0,15),".dat");
String Filename[]=f1.list(filefilter);
rst="";
for (int i=0;i<Filename.length ;i++) {
rst=rst+Filename+"/n";
}
if (rst.equals("") ){
//抛出异常
throw new ServletException("未找到回执文件");
}else
{
size=rst.getBytes();
}
}else
if ("SvrGetFileList".equals(request.getParameter("OpeType") )){
if (request.getParameter("FJDM") .equals("") ){
filefilter=new FilefilterClass("RZ00100","",".dat");
StrPath=ServletPath+"/";
}else
{
filefilter=new FilefilterClass("RZ00100","",request.getParameter("FJDM").toString()+".dat");
StrPath=ServletPath+"/"+request.getParameter("FJDM").toString() +"/";
}
//开始查找文件
File f2=new File(StrPath);
if(!f2.exists()){
throw new ServletException("未找到文件"+StrPath);
}
String Filename2[]=f2.list(filefilter);
rst="";
for (int i=0;i<Filename2.length ;i++) {
rst=rst+Filename2+"/n";
if (i>1024){break;}
}
if (rst.equals("") ){
//抛出异常
throw new ServletException("未找到文件");
}else
{
size=rst.getBytes();
}
}
else
if ("SvrGetDirList".equals(request.getParameter("OpeType"))){
File f3=new File(ServletPath+"/");
//filefilter=new FilefilterClass("RZ00101",request.getParameter("Nsr").substring(0,15),".dat");
//String DirName[]=f3.list(filefilter);
String DirName[]=f3.list();
rst="";
for (int i=0;i<DirName.length ;i++) {
File Strdir=new File(ServletPath+"/"+DirName);
if(Strdir.isDirectory() ){
if(DirName.length() ==9){
rst = rst + DirName + "/n";
}
}
}
if (rst.equals("") ){
//抛出异常
throw new ServletException("未找到文件");
}else
{
size=rst.getBytes();
}
}else
if ("GetFile".equals(request.getParameter("OpeType"))){
FileInputStream SrcF=null;
StrFile=request.getParameter("File") ;
if (StrFile.equals("")) {
//抛出异常
throw new ServletException("未指定文件名");
}
if (!StrFile.toUpperCase() .substring(0,7) .equals("RZ00101") ){
//抛出异常
throw new ServletException("文件名不合法");
}
if (StrFile.length() >40){
StrPath=ServletPath+"/"+StrFile.substring(36,45)+"/"+"rn/";
}else
{
StrPath=ServletPath+"/rn/";
}
//判断目录是否存在
File f3=new File(StrPath);
if(!f3.exists() ){
f3.mkdirs();
};
StrFile=StrPath+StrFile;
File f4=new File(StrFile);
if (!f4.exists() ){
//抛出异常
throw new ServletException("未找到文件:"+StrFile);
}
try{
try{
SrcF = new FileInputStream(f4);
}
catch (Throwable e) {
Thread.currentThread().sleep(3000);
SrcF = new FileInputStream(f4);
}
int filesize=(int)f4.length() ;
size=new byte[filesize];
SrcF.read(size) ;
}
finally {
SrcF.close();
}
}
else
if ("SvrGetFile".equals(request.getParameter("OpeType"))){
FileInputStream SrcF=null;
StrFile=request.getParameter("File") ;
if (StrFile.equals("")) {
//抛出异常
throw new ServletException("未指定文件名");
}
if (!StrFile.toUpperCase() .substring(0,7) .equals("RZ00100") ){
//抛出异常
throw new ServletException("文件名不合法");
}
if (StrFile.length() >40){
StrPath=ServletPath+"/"+StrFile.substring(36,45)+"/";
}else
{
StrPath=ServletPath+"/";
}
//判断目录是否存在
File f3=new File(StrPath);
if(!f3.exists() ){
f3.mkdirs();
};
StrFile=StrPath+StrFile;
File f4=new File(StrFile);
if (!f4.exists() ){
//抛出异常
throw new ServletException("未找到文件:"+StrFile);
}
try{
try{
SrcF=new FileInputStream(StrFile);
}
catch(Exception e){
Thread.currentThread().sleep(3000);
SrcF=new FileInputStream(StrFile);
}
int filesize=(int)f4.length() ;
size=new byte[filesize];
SrcF.read(size) ;
}
finally {
SrcF.close();
}
}
else
if ("DeleteFile".equals(request.getParameter("OpeType"))){
StrFile=request.getParameter("File") ;
if (StrFile.equals("")) {
//抛出异常
throw new ServletException("未指定文件名");
}
if (!StrFile.toUpperCase() .substring(0,7) .equals("RZ00101") ){
//抛出异常
throw new ServletException("文件名不合法");
}
if (StrFile.length() >40){
StrPath=ServletPath+"/"+StrFile.substring(36,45)+"/"+"rn/";
}else
{
StrPath=ServletPath+"/rn/";
}
//判断目录是否存在
File f3=new File(StrPath);
if(!f3.exists() ){
f3.mkdirs();
};
StrFile=StrPath+StrFile;
File f4=new File(StrFile);
if (!f4.exists() ){
//抛出异常
throw new ServletException("未找到文件");
}
if (f4.delete() ){
rst="OK!";
size=rst.getBytes();
}else
{
//抛出异常
throw new ServletException("无法删除文件,文件已不存在或可能在使用:"+StrFile);
}
}
else
if ("SvrDeleteFile".equals(request.getParameter("OpeType"))){
StrFile=request.getParameter("File") ;
if (StrFile.equals("")) {
//抛出异常
throw new ServletException("未指定文件名");
}
if (!StrFile.toUpperCase() .substring(0,7) .equals("RZ00100") ){
//抛出异常
throw new ServletException("文件名不合法");
}
if (StrFile.length() >40){
StrPath=ServletPath+"/"+StrFile.substring(36,45)+"/";
}else
{
StrPath=ServletPath+"/";
}
//判断目录是否存在
File f3=new File(StrPath);
if(!f3.exists() ){
f3.mkdirs();
};
StrFile=StrPath+StrFile;
File f4=new File(StrFile);
if (!f4.exists() ){
//抛出异常
throw new ServletException("未找到文件");
}
if (f4.delete() ){
rst="OK!";
size=rst.getBytes();
}else
{
//抛出异常
throw new ServletException("无法删除文件,文件已不存在或可能在使用:"+StrFile);
}
}
if (size.length==0){
throw new ServletException("URL不合法");
}
}
catch(Throwable e) {
rst="Err"+e.getMessage() ;
size=rst.getBytes();
}
finally{
ServletOutputStream out=response.getOutputStream();
//out.print(rst) ;
out.write(size);
}
}