commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mundell, R. (Ronald)" <Ronal...@Nedbank.co.za>
Subject FileUpload Errors
Date Thu, 16 Nov 2006 06:04:32 GMT
Good Day

I downloaded on of the examples from the website site
(http://www.onjava.com/onjava/2003/06/25/examples/commons1src.zip) and am
having problems getting it to work. I don't know what the problem is. I have
included the latest commons-fileupload.jar file. I also have included
org.apache.commons.is_1.2.0.jar.

The error I am getting is as follows. I also have included my source


HTTP Status 500 - 

----------------------------------------------------------------------------
----

type Exception report

message 

description The server encountered an internal error () that prevented it
from fulfilling this request.

exception 

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

An error occurred at line: 2 in the jsp file:
/FileUploadDemo/commons1src/fileupload/fileuploaddemo.jsp
Generated servlet error:
C:\Documents and
Settings\Ronald\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localh
ost\dms\org\apache\jsp\FileUploadDemo\commons1src\fileupload\fileuploaddemo_
jsp.java:52: cannot find symbol
symbol  : variable ServletFileUpload
location: class
org.apache.jsp.FileUploadDemo.commons1src.fileupload.fileuploaddemo_jsp
	boolean isMultipart = ServletFileUpload.isMultipartContent(request);
                              ^


An error occurred at line: 2 in the jsp file:
/FileUploadDemo/commons1src/fileupload/fileuploaddemo.jsp
Generated servlet error:
C:\Documents and
Settings\Ronald\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localh
ost\dms\org\apache\jsp\FileUploadDemo\commons1src\fileupload\fileuploaddemo_
jsp.java:61: cannot find symbol
symbol  : class DiskFileItemFactory
location: class
org.apache.jsp.FileUploadDemo.commons1src.fileupload.fileuploaddemo_jsp
        DiskFileItemFactory factory = new DiskFileItemFactory();
        ^


An error occurred at line: 2 in the jsp file:
/FileUploadDemo/commons1src/fileupload/fileuploaddemo.jsp
Generated servlet error:
C:\Documents and
Settings\Ronald\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localh
ost\dms\org\apache\jsp\FileUploadDemo\commons1src\fileupload\fileuploaddemo_
jsp.java:61: cannot find symbol
symbol  : class DiskFileItemFactory
location: class
org.apache.jsp.FileUploadDemo.commons1src.fileupload.fileuploaddemo_jsp
        DiskFileItemFactory factory = new DiskFileItemFactory();
                                          ^


An error occurred at line: 2 in the jsp file:
/FileUploadDemo/commons1src/fileupload/fileuploaddemo.jsp
Generated servlet error:
C:\Documents and
Settings\Ronald\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localh
ost\dms\org\apache\jsp\FileUploadDemo\commons1src\fileupload\fileuploaddemo_
jsp.java:65: cannot find symbol
symbol  : class ServletFileUpload
location: class
org.apache.jsp.FileUploadDemo.commons1src.fileupload.fileuploaddemo_jsp
	ServletFileUpload upload = new ServletFileUpload();
        ^


An error occurred at line: 2 in the jsp file:
/FileUploadDemo/commons1src/fileupload/fileuploaddemo.jsp
Generated servlet error:
C:\Documents and
Settings\Ronald\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localh
ost\dms\org\apache\jsp\FileUploadDemo\commons1src\fileupload\fileuploaddemo_
jsp.java:65: cannot find symbol
symbol  : class ServletFileUpload
location: class
org.apache.jsp.FileUploadDemo.commons1src.fileupload.fileuploaddemo_jsp
	ServletFileUpload upload = new ServletFileUpload();
                                       ^
5 errors



	
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWra
pper.java:510)
	
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
75)
	
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter
.java:368)


root cause 

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

An error occurred at line: 2 in the jsp file:
/FileUploadDemo/commons1src/fileupload/fileuploaddemo.jsp
Generated servlet error:
C:\Documents and
Settings\Ronald\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localh
ost\dms\org\apache\jsp\FileUploadDemo\commons1src\fileupload\fileuploaddemo_
jsp.java:52: cannot find symbol
symbol  : variable ServletFileUpload
location: class
org.apache.jsp.FileUploadDemo.commons1src.fileupload.fileuploaddemo_jsp
	boolean isMultipart = ServletFileUpload.isMultipartContent(request);
                              ^


An error occurred at line: 2 in the jsp file:
/FileUploadDemo/commons1src/fileupload/fileuploaddemo.jsp
Generated servlet error:
C:\Documents and
Settings\Ronald\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localh
ost\dms\org\apache\jsp\FileUploadDemo\commons1src\fileupload\fileuploaddemo_
jsp.java:61: cannot find symbol
symbol  : class DiskFileItemFactory
location: class
org.apache.jsp.FileUploadDemo.commons1src.fileupload.fileuploaddemo_jsp
        DiskFileItemFactory factory = new DiskFileItemFactory();
        ^


An error occurred at line: 2 in the jsp file:
/FileUploadDemo/commons1src/fileupload/fileuploaddemo.jsp
Generated servlet error:
C:\Documents and
Settings\Ronald\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localh
ost\dms\org\apache\jsp\FileUploadDemo\commons1src\fileupload\fileuploaddemo_
jsp.java:61: cannot find symbol
symbol  : class DiskFileItemFactory
location: class
org.apache.jsp.FileUploadDemo.commons1src.fileupload.fileuploaddemo_jsp
        DiskFileItemFactory factory = new DiskFileItemFactory();
                                          ^


An error occurred at line: 2 in the jsp file:
/FileUploadDemo/commons1src/fileupload/fileuploaddemo.jsp
Generated servlet error:
C:\Documents and
Settings\Ronald\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localh
ost\dms\org\apache\jsp\FileUploadDemo\commons1src\fileupload\fileuploaddemo_
jsp.java:65: cannot find symbol
symbol  : class ServletFileUpload
location: class
org.apache.jsp.FileUploadDemo.commons1src.fileupload.fileuploaddemo_jsp
	ServletFileUpload upload = new ServletFileUpload();
        ^


An error occurred at line: 2 in the jsp file:
/FileUploadDemo/commons1src/fileupload/fileuploaddemo.jsp
Generated servlet error:
C:\Documents and
Settings\Ronald\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localh
ost\dms\org\apache\jsp\FileUploadDemo\commons1src\fileupload\fileuploaddemo_
jsp.java:65: cannot find symbol
symbol  : class ServletFileUpload
location: class
org.apache.jsp.FileUploadDemo.commons1src.fileupload.fileuploaddemo_jsp
	ServletFileUpload upload = new ServletFileUpload();
                                       ^
5 errors



	
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandle
r.java:84)
	
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:3
28)
	
org.apache.jasper.compiler.AntCompiler.generateClass(AntCompiler.java:249)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
	
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:5
63)
	
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
03)
	
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter
.java:368)


note The full stack trace of the root cause is available in the Apache
Tomcat/5.5.17 logs.


----------------------------------------------------------------------------
----

Apache Tomcat/5.5.17


HTML
+++++
<!-- saved from url=(0022)http://internet.e-mail -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>Upload Test</title>
  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body>

	<form name="myform" action="fileuploaddemo.jsp" method="post"
enctype="multipart/form-data">
		Specify your name:<br/>
			<input type="text" name="name" size="15"/><br/>
		Specify your Image:<br/>
			<input type="file" name="myimage"><br/>
		Specify your File:<br/>
			<input type="file" name="myfile"><br/><br/>

		<input type="submit" name="Submit" value="Submit your
files"/>
	</form>

</body>
</html>


Fileupload.jsp
++++++++++++++
<%@ page import="org.apache.commons.fileupload.*,org.apache.commons.io.*,
java.util.List, java.io.File, java.util.Iterator" %>
<%
	
	// first check if the upload request coming in is a multipart
request
	boolean isMultipart = ServletFileUpload.isMultipartContent(request);
	
	// if not, send to message page with the error message
	if(!isMultipart){
		request.setAttribute("msg", "Request was not multipart!");
		request.getRequestDispatcher("msg.jsp").forward(request,
response);
		return;
	}
	
        DiskFileItemFactory factory = new DiskFileItemFactory();
        factory.setSizeThreshold( 1 );
        factory.setRepository("c:\\Temp");
	// now lets create a handler for the upload request.
	ServletFileUpload upload = new ServletFileUpload();
        upload.setSizeMax(10 * 1024 * 1024);
	
	// parse this request by the handler
	// this gives us a list of items from the request
	List items = upload.parseRequest(request);
	
	// now iterate over this list
	Iterator itr = items.iterator();
	
	while(itr.hasNext()){
	
		FileItem item = (FileItem) itr.next();
		
		// check if the current item is a form field or an uploaded
file
		if(item.isFormField()){
			
			// get the name of the field
			String fieldName = item.getFieldName();
			
			// if it is name, we can set it in request to thank
the user
			if(fieldName.equals("name"))
				request.setAttribute("msg", "Thank You: " +
item.getString());
				
		} else {
		
			// the item must be an uploaded file
			// save it to disk			
			File fullFile = new File(item.getName());

			File savedFile = new
File(getServletContext().getRealPath("/"), fullFile.getName());
			item.write(savedFile);
		}
	}
	
	// finally send to the msg page
	request.getRequestDispatcher("msg.jsp").forward(request, response);

%>


Msg.jsp
+++++++

If someone can help me it would be greatly appreciated.

Thank you

Ronald Mundell
 


********************
Nedbank Limited Reg No 1951/000009/06. The following link displays the names of the Nedbank
Board of Directors and Company Secretary. [ http://www.nedbank.co.za/terms/DirectorsNedbank.htm
]
This email is confidential and is intended for the addressee only. The following link will
take you to Nedbank's legal notice. [ http://www.nedbank.co.za/terms/EmailDisclaimer.htm ]
********************

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message