//some code.... DiskFileUpload fu = new DiskFileUpload();" />
开发者

Apache commons -> File Upload -> DiskFileUpload cannot be resolved

<%@ page import="org.apache.commons.fileupload.*" %> //some code.... DiskFileUpload fu = new DiskFileUpload();

I am trying to use the apache commons function DiskFileUpload, but it got an exception because fileupload.jar cannot be find. I look at other responses related to the similar problem in this forum and people suggested to add the file in WEB-INF/lib, and I try it but it is not working for me.

Maybe I put it in a wrong location? My jsp path is:apache-tomcat-6.0.29/webapps/ROOT/ClockAdmin/upload.jsp and the WEB-INF is:apache-tomcat-6.0.29/webapps/WEB-INF/commons-fileupload-1.2.2.jar lib/ I look at other post but it is still not working: Apache commons -> File Upload -> parseRequest() error

And I got the following exception:

    org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 36 in the jsp file: /ClockAdmin/uploader2.jsp
DiskFileUpload cannot be resolved to a type
33:             System.out.println( "CONTENT-LENGHT" +  request.getContentLength());
34:             System.out.println("session id = " + session.getId());
35: 
36:             DiskFileUpload fu = new DiskFileUpload();
37:             // maximum size before a FileUploadException will be thrown
38:             fu.setSizeMax(5000000);
39:             // maximum size that will be stored in memory


An error occurred at line: 36 in the jsp file: /ClockAdmin/uploader2.jsp
DiskFileUpload cannot be resolved to a type
33:             System.out.println( "CONTENT-LENGHT" +  request.getContentLength());
34:             System.out.println("session id = " + session.getId());
35: 
36:             DiskFileUpload fu = new DiskFileUpload();
37:             // maximum size before a FileUploadException will be thrown
38:             fu.setSizeMax(5000000);
39:             // maximum size that will be stored in memory


An error occurred at line: 48 in the jsp file: /ClockAdmin/uploader2.jsp
FileItem cannot be resolved to a type
45:             Iterator item = fileItems.iterator();
46:             while(item.hasNext())
47:             {
48:                 FileItem fi = (FileItem) item.next();
49:                 if(fi.isFormField())
50:                 {
51:                     continue;


An error occurred at line: 48 in the jsp file: /ClockAdmin/uploader2.jsp
FileItem cannot be resolved to a type
45:             Iterator item = fileItems.iterator();
46:             while(item.hasNext())
47:             {
48:                 FileItem fi = (FileItem) item.next();
49:                 if(fi.isFormField())
50:                 {
51:                     continue;


Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
    org.apa开发者_如何学JAVAche.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


You need to drop JARs in /WEB-INF/lib folder, not in /WEB-INF.


I had to manually deploy the WAR file by bouncing the Tomcat server. This unpacked the WAR and when the server started back up, it did not throw any exceptions. I can only imagine that I have a misconfiguration in the Tomcat setup to permit the manifest to be properly closed and reopened.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜