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>");
}