fileupload

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

fileupload

Tim Oliver Wagner
Hello,
I write a web application with JSPs (running at tomcat-server). My problem
occours with uploadingfiles.

At the jsp-Page I defined this HTML-FORM (browser: Mozilla Firefox):

<h1>Hochladen einer Datei</h1>
       
<form action=<%= request.getRequestURL()%> method="post"
ENCTYPE='multipart/form-data'>
        Datei: <input type="file" size="50" name="datei" maxlength="10000"
accept="text/*"/><br/>
        <input type="submit" name="action" value="upload file" />
</form>

Now I try to parse the Multipart-Message:
if (FileUpload.isMultipartContent(request)) {
        try {
                // ENCTYPE='multipart/form-data' Daten rauslesen!!!
                FileItemFactory factory = new DiskFileItemFactory();
                ServletFileUpload upl = new ServletFileUpload(factory);
                java.util.List items = upl.parseRequest(request);
                .........

At the last line (java.util.List items ....) the error accurs. But I dont
understand why ...

I hope someone can help me.

tia

Oli

PS:
I think I did everything in that way like at
http://jakarta.apache.org/commons/fileupload/using.html descibed.

attachment0 (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: fileupload

Knezevic, Mihael
your environment (f.e. software versions) and the exact error message
would help to identify the error.

> -----Original Message-----
> From: Tim Oliver Wagner [mailto:[hidden email]]
> Sent: Tuesday, January 24, 2006 11:54 AM
> To: [hidden email]
> Subject: fileupload
>
> Hello,
> I write a web application with JSPs (running at
> tomcat-server). My problem
> occours with uploadingfiles.
>
> At the jsp-Page I defined this HTML-FORM (browser: Mozilla Firefox):
>
> <h1>Hochladen einer Datei</h1>
>
> <form action=<%= request.getRequestURL()%> method="post"
> ENCTYPE='multipart/form-data'>
> Datei: <input type="file" size="50" name="datei"
> maxlength="10000"
> accept="text/*"/><br/>
> <input type="submit" name="action" value="upload file" />
> </form>
>
> Now I try to parse the Multipart-Message:
> if (FileUpload.isMultipartContent(request)) {
> try {
> // ENCTYPE='multipart/form-data' Daten rauslesen!!!
> FileItemFactory factory = new DiskFileItemFactory();
> ServletFileUpload upl = new ServletFileUpload(factory);
> java.util.List items = upl.parseRequest(request);
> .........
>
> At the last line (java.util.List items ....) the error
> accurs. But I dont
> understand why ...
>
> I hope someone can help me.
>
> tia
>
> Oli
>
> PS:
> I think I did everything in that way like at
> http://jakarta.apache.org/commons/fileupload/using.html descibed.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: fileupload

Dakota Jack
In reply to this post by Tim Oliver Wagner
Are you using something like Struts, which grabs the request from you with
multiparts?  Try seeing if you have the request.

On 1/24/06, Tim Oliver Wagner <[hidden email]> wrote:

>
> Hello,
> I write a web application with JSPs (running at tomcat-server). My problem
> occours with uploadingfiles.
>
> At the jsp-Page I defined this HTML-FORM (browser: Mozilla Firefox):
>
> <h1>Hochladen einer Datei</h1>
>
> <form action=<%= request.getRequestURL()%> method="post"
> ENCTYPE='multipart/form-data'>
>         Datei: <input type="file" size="50" name="datei" maxlength="10000"
> accept="text/*"/><br/>
>         <input type="submit" name="action" value="upload file" />
> </form>
>
> Now I try to parse the Multipart-Message:
> if (FileUpload.isMultipartContent(request)) {
>         try {
>                 // ENCTYPE='multipart/form-data' Daten rauslesen!!!
>                 FileItemFactory factory = new DiskFileItemFactory();
>                 ServletFileUpload upl = new ServletFileUpload(factory);
>                 java.util.List items = upl.parseRequest(request);
>                 .........
>
> At the last line (java.util.List items ....) the error accurs. But I dont
> understand why ...
>
> I hope someone can help me.
>
> tia
>
> Oli
>
> PS:
> I think I did everything in that way like at
> http://jakarta.apache.org/commons/fileupload/using.html descibed.
>
>
>


--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~
Reply | Threaded
Open this post in threaded view
|

Re: fileupload

Tim Oliver Wagner
I don't think that I use struts. I just wan't a simple fileupload. (later I
want to write this file in an DB ). But first I have to solve the Problem to
upload the file to the Server and parse the request-Object ... later I try to
put the Data to the DB ...

The other message I answert with my complete source from JSP ... additional
the error-Message from the tomcat ...

greets, oli

Am Dienstag 24 Januar 2006 16:17 schrieb Dakota Jack:

> Are you using something like Struts, which grabs the request from you with
> multiparts?  Try seeing if you have the request.
>
> On 1/24/06, Tim Oliver Wagner <[hidden email]> wrote:
> > Hello,
> > I write a web application with JSPs (running at tomcat-server). My
> > problem occours with uploadingfiles.
> >
> > At the jsp-Page I defined this HTML-FORM (browser: Mozilla Firefox):
> >
> > <h1>Hochladen einer Datei</h1>
> >
> > <form action=<%= request.getRequestURL()%> method="post"
> > ENCTYPE='multipart/form-data'>
> >         Datei: <input type="file" size="50" name="datei"
> > maxlength="10000" accept="text/*"/><br/>
> >         <input type="submit" name="action" value="upload file" />
> > </form>
> >
> > Now I try to parse the Multipart-Message:
> > if (FileUpload.isMultipartContent(request)) {
> >         try {
> >                 // ENCTYPE='multipart/form-data' Daten rauslesen!!!
> >                 FileItemFactory factory = new DiskFileItemFactory();
> >                 ServletFileUpload upl = new ServletFileUpload(factory);
> >                 java.util.List items = upl.parseRequest(request);
> >                 .........
> >
> > At the last line (java.util.List items ....) the error accurs. But I dont
> > understand why ...
> >
> > I hope someone can help me.
> >
> > tia
> >
> > Oli
> >
> > PS:
> > I think I did everything in that way like at
> > http://jakarta.apache.org/commons/fileupload/using.html descibed.
>
> --
> "You can lead a horse to water but you cannot make it float on its back."
> ~Dakota Jack~

attachment0 (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: fileupload

Tim Oliver Wagner
In reply to this post by Knezevic, Mihael
Am Dienstag 24 Januar 2006 14:29 schrieb Knezevic, Mihael:
> your environment (f.e. software versions) and the exact error message
> would help to identify the error.

Hello,
here comes the information (Programm-Versions, Source from JSP,
Error-Message). If you need more please tell me ...

I don't know what I can try anymore ... I hope someone can help me to solve
the problem.

thanks in advance

Oli

PS:
I try to attach additionaly the error message and the jsp to the mail.

********************************************************************************************
Programm-Versions:
==============

java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

-rw-r--r--  1 tow users  54K 2006-01-21 12:16 activation.jar
-rw-r--r--  1 tow users  32K 2005-12-23 05:57 commons-fileupload-1.1.jar
-rw-r--r--  1 tow users 347K 2006-01-21 01:31 mail.jar

Apache-Tomcat 5.5.12

*********************************************************************************************
Source-JSP:
=========
<%@ page import ="java.io.*" %>
<%@ page import ="org.apache.commons.fileupload.*" %>
<%@ page import ="org.apache.commons.fileupload.servlet.*" %>
<%@ page import ="org.apache.commons.fileupload.disk.*" %>
<%@ page import ="java.util.*" %>

<html>

<head><title>Test</title></head>

<body>
        <h1> Test </h1>

        <%
                if (FileUpload.isMultipartContent(request)) {
                        try {
                                out.println("<h3> Inhalt des
Geparsten:</h3>");
                                // ENCTYPE='multipart/form-data' Daten
rauslesen!!!
                                FileItemFactory factory = new
DiskFileItemFactory();
                                ServletFileUpload upl = new
ServletFileUpload(factory);
// as soon as I uncomment the next line ... tomcat can't execute the jsp.
//                              java.util.List items =
upl.parseRequest(request);

                        } catch (Exception e) {
                                e.printStackTrace();
                        }
                }


                out.println("<h3>request Variable:</h3>");
                out.println("<br/>request.getQueryString(): " +
request.getQueryString() + "<br/>");
                out.println("request.getRequestURL(): " +
request.getRequestURL() + "<br/>");

                out.println("<h3>Multipart?</h3>");
                out.println("Ist Multipart Request (File Upload)?: " +
FileUpload.isMultipartContent(request) + "<br/>");
                %>


        <h1>Upload a file:</h1>

        <form action=<%= request.getRequestURL()%> method="post"
ENCTYPE='multipart/form-data'>
                Datei: <input type="file" size="50" name="datei"
maxlength="10000" accept="text/*"/><br/>
                <input type="submit" name="action" value="upload file" />
        </form>

</body>

</html>

*********************************************************************************************
Error-Msg:
=======
HTTP Status 500 -

type Exception report

message

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

exception

javax.servlet.ServletException:
org/apache/commons/io/output/DeferredFileOutputStream
       
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
       
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
       
org.apache.jsp.fileupload_jsp._jspService(org.apache.jsp.fileupload_jsp:134)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
       
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
       
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)

root cause

java.lang.NoClassDefFoundError:
org/apache/commons/io/output/DeferredFileOutputStream
       
org.apache.commons.fileupload.disk.DiskFileItemFactory.createItem(DiskFileItemFactory.java:179)
       
org.apache.commons.fileupload.FileUploadBase.createItem(FileUploadBase.java:500)
       
org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:367)
       
org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:116)
       
org.apache.jsp.fileupload_jsp._jspService(org.apache.jsp.fileupload_jsp:72)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
       
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
       
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)

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

errorVonTomcat.txt (1K) Download Attachment
fileupload.jsp (1K) Download Attachment
attachment2 (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: fileupload

Knezevic, Mihael
In reply to this post by Tim Oliver Wagner
java.lang.NoClassDefFoundError:
org/apache/commons/io/output/DeferredFileOutputStream

it seems that you don't have commons-io in your classpath. just download it and add it. perhaps you'll need the oro package too.

> -----Original Message-----
> From: Tim Oliver Wagner [mailto:[hidden email]]
> Sent: Wednesday, January 25, 2006 11:58 AM
> To: [hidden email]
> Subject: Re: fileupload
>
> Am Dienstag 24 Januar 2006 14:29 schrieb Knezevic, Mihael:
> > your environment (f.e. software versions) and the exact
> error message
> > would help to identify the error.
>
> Hello,
> here comes the information (Programm-Versions, Source from JSP,
> Error-Message). If you need more please tell me ...
>
> I don't know what I can try anymore ... I hope someone can
> help me to solve
> the problem.
>
> thanks in advance
>
> Oli
>
> PS:
> I try to attach additionaly the error message and the jsp to the mail.
>
> **************************************************************
> ******************************
> Programm-Versions:
> ==============
>
> java version "1.5.0_06"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
> Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
>
> -rw-r--r--  1 tow users  54K 2006-01-21 12:16 activation.jar
> -rw-r--r--  1 tow users  32K 2005-12-23 05:57
> commons-fileupload-1.1.jar
> -rw-r--r--  1 tow users 347K 2006-01-21 01:31 mail.jar
>
> Apache-Tomcat 5.5.12
>
> **************************************************************
> *******************************
> Source-JSP:
> =========
> <%@ page import ="java.io.*" %>
> <%@ page import ="org.apache.commons.fileupload.*" %>
> <%@ page import ="org.apache.commons.fileupload.servlet.*" %>
> <%@ page import ="org.apache.commons.fileupload.disk.*" %>
> <%@ page import ="java.util.*" %>
>
> <html>
>
> <head><title>Test</title></head>
>
> <body>
>         <h1> Test </h1>
>
>         <%
>                 if (FileUpload.isMultipartContent(request)) {
>                         try {
>                                 out.println("<h3> Inhalt des
> Geparsten:</h3>");
>                                 //
> ENCTYPE='multipart/form-data' Daten
> rauslesen!!!
>                                 FileItemFactory factory = new
> DiskFileItemFactory();
>                                 ServletFileUpload upl = new
> ServletFileUpload(factory);
> // as soon as I uncomment the next line ... tomcat can't
> execute the jsp.
> //                              java.util.List items =
> upl.parseRequest(request);
>
>                         } catch (Exception e) {
>                                 e.printStackTrace();
>                         }
>                 }
>
>
>                 out.println("<h3>request Variable:</h3>");
>                 out.println("<br/>request.getQueryString(): " +
> request.getQueryString() + "<br/>");
>                 out.println("request.getRequestURL(): " +
> request.getRequestURL() + "<br/>");
>
>                 out.println("<h3>Multipart?</h3>");
>                 out.println("Ist Multipart Request (File
> Upload)?: " +
> FileUpload.isMultipartContent(request) + "<br/>");
>                 %>
>
>
>         <h1>Upload a file:</h1>
>
>         <form action=<%= request.getRequestURL()%> method="post"
> ENCTYPE='multipart/form-data'>
>                 Datei: <input type="file" size="50" name="datei"
> maxlength="10000" accept="text/*"/><br/>
>                 <input type="submit" name="action"
> value="upload file" />
>         </form>
>
> </body>
>
> </html>
>
> **************************************************************
> *******************************
> Error-Msg:
> =======
> HTTP Status 500 -
>
> type Exception report
>
> message
>
> description The server encountered an internal error () that
> prevented it from
> fulfilling this request.
>
> exception
>
> javax.servlet.ServletException:
> org/apache/commons/io/output/DeferredFileOutputStream
>        
> org.apache.jasper.runtime.PageContextImpl.doHandlePageExceptio
> n(PageContextImpl.java:848)
>        
> org.apache.jasper.runtime.PageContextImpl.handlePageException(
> PageContextImpl.java:781)
>        
> org.apache.jsp.fileupload_jsp._jspService(org.apache.jsp.fileu
> pload_jsp:134)
>        
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
>         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>        
> org.apache.jasper.servlet.JspServletWrapper.service(JspServlet
> Wrapper.java:322)
>        
> 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)
>
> root cause
>
> java.lang.NoClassDefFoundError:
> org/apache/commons/io/output/DeferredFileOutputStream
>        
> org.apache.commons.fileupload.disk.DiskFileItemFactory.createI
> tem(DiskFileItemFactory.java:179)
>        
> org.apache.commons.fileupload.FileUploadBase.createItem(FileUp
> loadBase.java:500)
>        
> org.apache.commons.fileupload.FileUploadBase.parseRequest(File
> UploadBase.java:367)
>        
> org.apache.commons.fileupload.servlet.ServletFileUpload.parseR
> equest(ServletFileUpload.java:116)
>        
> org.apache.jsp.fileupload_jsp._jspService(org.apache.jsp.fileu
> pload_jsp:72)
>        
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
>         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>        
> org.apache.jasper.servlet.JspServletWrapper.service(JspServlet
> Wrapper.java:322)
>        
> 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)
>
> note The full stack trace of the root cause is available in
> the Apache
> Tomcat/5.5.12 logs.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: fileupload

Tim Oliver Wagner
Hello,
thanks for your answer ... that was the Problem! :-)

Now it works, I can upload a file to the Server. :-)

Thanks,

Oli

Am Mittwoch 25 Januar 2006 14:12 schrieb Knezevic, Mihael:
> java.lang.NoClassDefFoundError:
> org/apache/commons/io/output/DeferredFileOutputStream
>
> it seems that you don't have commons-io in your classpath. just download it
> and add it. perhaps you'll need the oro package too.

attachment0 (196 bytes) Download Attachment