java上传文件(200分)

  • 主题发起人 主题发起人 zhouzjun
  • 开始时间 开始时间
Z

zhouzjun

Unregistered / Unconfirmed
GUEST, unregistred user!
websphere 3.5 我在servlet中使用com.jspsmart.upload类上传文件是可以用的,
而且文件最大到1M均可以使用;
但在websphere 4.0中,同样的程序,只能上传5k以下的数据,
而大一些的文件,服务器端会出现死循环,CPU占用100%,
是否com.jspsmart.upload要修改?
 
是不是你使用smartupload版本太低了?我们用的也是was 4.0,用的还算挺好的吧。
 
jsp使用正常
servlet出问题
 
Jsp方法使用正常:
<%@ page language="java" import="com.jspsmart.upload.*"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<HTML>
<BODY BGCOLOR="white">
<H1>jspSmartUpload : Sample 1</H1>
<HR>
<%
int count=0;

mySmartUpload.initialize(pageContext);
mySmartUpload.setTotalMaxFileSize(10000000);
mySmartUpload.upload();
try {
count = mySmartUpload.save("c:/upload");
out.println(count + " file(s) uploaded.");
} catch (Exception e) {
out.println(e.toString());
}

%>
</BODY>
</HTML>
servlet有问题:
/**
* Handles POST requests
*/
protected voiddo
Post(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<BODY BGCOLOR='white'>");
out.println("<H1>jspSmartUpload : Servlet Sample</H1>");
out.println("<HR>");
// Variables
int count=0;
SmartUpload mySmartUpload = new SmartUpload();
try {
// Initialization
mySmartUpload.initialize(config,request,response);
// Upload
mySmartUpload.upload();
// Save the file with the original name
// in a virtual path of the web server
count = mySmartUpload.save("c:/upload");//mySmartUpload.getRequest().getParameter("PATH"));

// Display the result
out.println(count + " file uploaded.");
} catch (Exception e){
out.println("Unable to upload the file.<br>");
out.println("Error : " + e.toString());
}

out.println("</BODY>");
out.println("</HTML>");
}
 
已经解决,多谢关心!只是无法取消问题。
 
接受答案了.
 
后退
顶部