Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to compile class for JSP

 
Darren Alexandria
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I have been struggling to solve this problem for 2 days now, my task is to upload multiple files at the same time.

here is my code:

index.jsp



multifileupload.jsp



here's the error:

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



An error occurred at line: 21 in the jsp file: /multifileUpload.jsp
ServletFileUpload cannot be resolved
18: </td>
19: </tr>
20: <%
21: boolean isMultipart = ServletFileUpload.isMultipartContent(request);
22: if (!isMultipart)
23: {
24: }


An error occurred at line: 27 in the jsp file: /multifileUpload.jsp
FileItemFactory cannot be resolved to a type
24: }
25: else
26: {
27: FileItemFactory factory = new DiskFileItemFactory();
28: ServletFileUpload upload = new ServletFileUpload(factory);
29: List items = null;
30: try


An error occurred at line: 27 in the jsp file: /multifileUpload.jsp
DiskFileItemFactory cannot be resolved to a type
24: }
25: else
26: {
27: FileItemFactory factory = new DiskFileItemFactory();
28: ServletFileUpload upload = new ServletFileUpload(factory);
29: List items = null;
30: try


An error occurred at line: 28 in the jsp file: /multifileUpload.jsp
ServletFileUpload cannot be resolved to a type
25: else
26: {
27: FileItemFactory factory = new DiskFileItemFactory();
28: ServletFileUpload upload = new ServletFileUpload(factory);
29: List items = null;
30: try
31: {


An error occurred at line: 28 in the jsp file: /multifileUpload.jsp
ServletFileUpload cannot be resolved to a type
25: else
26: {
27: FileItemFactory factory = new DiskFileItemFactory();
28: ServletFileUpload upload = new ServletFileUpload(factory);
29: List items = null;
30: try
31: {


An error occurred at line: 34 in the jsp file: /multifileUpload.jsp
FileUploadException cannot be resolved to a type
31: {
32: items = upload.parseRequest(request);
33: }
34: catch (FileUploadException e)
35: {
36: e.printStackTrace();
37: }


An error occurred at line: 36 in the jsp file: /multifileUpload.jsp
e cannot be resolved
33: }
34: catch (FileUploadException e)
35: {
36: e.printStackTrace();
37: }
38:
39: Iterator itr = items.iterator();


An error occurred at line: 42 in the jsp file: /multifileUpload.jsp
FileItem cannot be resolved to a type
39: Iterator itr = items.iterator();
40: while (itr.hasNext())
41: {
42: FileItem item = (FileItem) itr.next();
43:
44: if (item.isFormField())
45: {


An error occurred at line: 42 in the jsp file: /multifileUpload.jsp
FileItem cannot be resolved to a type
39: Iterator itr = items.iterator();
40: while (itr.hasNext())
41: {
42: FileItem item = (FileItem) itr.next();
43:
44: if (item.isFormField())
45: {

here's the stack trace:

Stacktrace:
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Thread.java:595)


Can anyone please give me an advice?
This is the first time I am developing a REAL appplication so please, i need your help.

Thanks.

God bless.

Dada
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like the container can not find the upload library that you're using.
Where did you put it?
 
Darren Alexandria
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added the libraries in the build path of the Project. Is that the right thing to do? Or I have to put it somewhere else?

Thanks for your reply.
 
Darren Alexandria
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, I am using Eclipse 3.2 with MyEclipse 5.0M1 Plugin and Apache Tomcat 5.5.23.

Thanks so much.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put the library in your WEB-INF/lib directory.
 
Darren Alexandria
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay. I'll try to place my libraries in the WEB-INF/lib folder.
I'll do it just right about now.

Thanks. Hope this will do it.
 
Darren Alexandria
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it worked! Thanks so much!

The problem now is that the files that I am supposed to upload doesn't show up in the folder I specified (uploadedFiles). If I make a folder named uploadedFiles, the upload doesn't work. But if i don't make the said folder and run the program, an item with a name of uploadedFiles with a type of File is made. And I can't view the contents if it has one. It has 0 KB. why is this so?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure that naming all input tags "name" is a good idea. Try to give each input tag a different name.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic