jakarta comman fileupload errors...

I'm using jakarta Fileupload pakage....

i'm getting this exception...

javax.servlet.ServletException: org/apache/commons/io/output/DeferredFileOutputStream
      org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
      org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
      org.apache.jsp.ProcessFileUpload_jsp._jspService(ProcessFileUpload_jsp.java:97)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream
      org.apache.commons.fileupload.DefaultFileItemFactory.createItem(DefaultFileItemFactory.java:102)
      org.apache.commons.fileupload.FileUploadBase.createItem(FileUploadBase.java:500)
      org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:367)
      org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:268)
      org.apache.jsp.ProcessFileUpload_jsp._jspService(ProcessFileUpload_jsp.java:65)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)



Please help out on how to resolve this...
LVL 10
jagadeesh_motamarriAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
You need the commons IO classes in your classpath
0
jagadeesh_motamarriAuthor Commented:
Now different error comes....

HTTP Status 404 - E:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\TrackingSystem\f:\capstone course\scope_1_0.doc (The filename, directory name, or volume label syntax is incorrect)

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

type Status report

message E:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\TrackingSystem\f:\capstone course\scope_1_0.doc (The filename, directory name, or volume label syntax is incorrect)

description The requested resource (E:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\TrackingSystem\f:\capstone course\scope_1_0.doc (The filename, directory name, or volume label syntax is incorrect)) is not available.



But the file is available on the desktop ...


0
jagadeesh_motamarriAuthor Commented:
Here is the sample code that i'm using....

UploadFiles.html

<HTML>
  <HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252"/>
    <TITLE>File Upload Page</TITLE>
  </HEAD>
  <BODY>Upload Files
    <FORM name="filesForm" action="ProcessFileUpload.jsp"
    method="post" enctype="multipart/form-data">
        File 1:<input type="file" name="file1"/><br/>
        File 2:<input type="file" name="file2"/><br/>
        File 3:<input type="file" name="file3"/><br/>
        <input type="submit" name="Submit" value="Upload Files"/>
    </FORM>
  </BODY>
</HTML>



and the ProcessFileUpload.jsp is ...


<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="org.apache.commons.fileupload.DiskFileUpload"%>
<%@ page import="org.apache.commons.fileupload.FileItem"%>
<%@ page import="org.apache.commons.io.*"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="java.io.File"%>
html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Process File Upload</title>
</head>
<%
        System.out.println("Content Type ="+request.getContentType());

        DiskFileUpload fu = new DiskFileUpload();
        // If file size exceeds, a FileUploadException will be thrown
        fu.setSizeMax(10000000);

        List fileItems = fu.parseRequest(request);
        Iterator itr = fileItems.iterator();

        while(itr.hasNext()) {
          FileItem fi = (FileItem)itr.next();

          //Check if not form field so as to only handle the file inputs
          //else condition handles the submit button input
          if(!fi.isFormField()) {
            System.out.println("\nNAME: "+fi.getName());
            System.out.println("SIZE: "+fi.getSize());
            //System.out.println(fi.getOutputStream().toString());
            File fNew= new File(application.getRealPath("/"), fi.getName());

            System.out.println(fNew.getAbsolutePath());
            fi.write(fNew);
          }
          else {
            System.out.println("Field ="+fi.getFieldName());
          }
        }
%>
<body>
Upload Successful!!
</body>
</html>


i don't have a clue .....
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

jagadeesh_motamarriAuthor Commented:
i'm actually using this code to upload files to one of the tomcat directories....what changes do i need to make......even i can post this as another question...
0
objectsCommented:
>             File fNew= new File(application.getRealPath("/"), fi.getName());

thats inccorect, getName() returns the complete path
should be more like:

            File fNew= new File(application.getRealPath("/"), new File(fi.getName()).getName());
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jagadeesh_motamarriAuthor Commented:
but now...where is the file uploaded to...
0
jagadeesh_motamarriAuthor Commented:
i got it...thankz...
0
jagadeesh_motamarriAuthor Commented:
added to this how can i create a directory of my own name and store there...its creating in the root directory of my project folder itslef...

an someone help me...
0
objectsCommented:
File dir = new File(application.getRealPath("/"), "nameOfDirectory");
if (!dir.exists()) dir.mkdir();

File fNew= new File(dir, new File(fi.getName()).getName());
0
CEHJCommented:
:-)
0
jagadeesh_motamarriAuthor Commented:
since i thought i should post a new question...i declared the points...


now i'm able to create directories and store files into them...but still i'm getting this error...
HTTP Status 404 - E:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\TrackingSystem\nameOfDirectory (Access is denied)

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

type Status report

message E:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\TrackingSystem\nameOfDirectory (Access is denied)

description The requested resource (E:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\TrackingSystem\nameOfDirectory (Access is denied)) is not available.



...............and ofcourse "nameOfDirectory " is the newly created file and it does contain the file that i'm uploading
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.