You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Marc Collin <co...@laboiteaprog.com> on 2006/03/10 21:54:58 UTC

Re: upload file [FileUpload]

Le Vendredi 10 Mars 2006 15:41, Brian K. Wallace a écrit :
> As a note for mails, please prefix your subject with [FileUpload]
>
> Not sure what the results of the "......" were, but Eclipse compile-time
> and Tomcat runtime are two totally separate concerns. Eclipse needs the
> jars in the classpath to compile which is one configuration. Tomcat
> needs them available in WEB-INF/lib of the webapp in order to find them
> at runtime. (Make sure you address both the fileupload jar as well as
> its dependencies)


i copied manually jar file to  WEB-INF/lib and i get the same problem

> HTH
> Brian


-- 
www.laboiteaprog.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: upload file [FileUpload]

Posted by Marc Collin <co...@laboiteaprog.com>.
Le Dimanche 12 Mars 2006 11:41, Stephen Colebourne a écrit :
> Typo: enctypetype
>
> Stephen
>
ok corrected


DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);	
try{
  List items = upload.parseRequest(request);
  Iterator iter = items.iterator();
  if (iter.hasNext()) {
    FileItem item = (FileItem) iter.next();					
    File uploadedFile = new File(item.getName());
    try{
      item.write(uploadedFile);
    }catch (Exception e) {
      e.printStackTrace();
    }		
  } 
}catch (FileUploadException e) {
  e.printStackTrace();
}
request.getRequestDispatcher("corrector.jsp").forward(request,response);

the file seem uploaded, browser forwarm to corrector.jsp... but when i don't 
fine the file uploaded on the hd...


-- 
www.laboiteaprog.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: upload file [FileUpload]

Posted by Stephen Colebourne <sc...@btopenworld.com>.
Typo: enctypetype

Stephen

Marc Collin wrote:
> Le Dimanche 12 Mars 2006 02:08, Brian K. Wallace a écrit :
> 
>>Marc -
>>
>>  Make sure you're using POST, not GET on your form.
>>
>>Brian
>>
> 
> 
> i use post
> 
> 
> <form action="Upload" method="POST" enctypetype="multipart/form-data">
>           <input type="file" name="file">
>           <input type="SUBMIT" name="button" value="Envoie">
> </form>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: upload file [FileUpload]

Posted by Marc Collin <co...@laboiteaprog.com>.
Le Dimanche 12 Mars 2006 02:08, Brian K. Wallace a écrit :
> Marc -
>
>   Make sure you're using POST, not GET on your form.
>
> Brian
>

i use post


<form action="Upload" method="POST" enctypetype="multipart/form-data">
          <input type="file" name="file">
          <input type="SUBMIT" name="button" value="Envoie">
</form>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: upload file [FileUpload]

Posted by "Brian K. Wallace" <br...@transmorphix.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Marc -

  Make sure you're using POST, not GET on your form.

Brian
Marc Collin wrote:
> Le Vendredi 10 Mars 2006 16:28, Brian K. Wallace a écrit :
>> I wouldn't use "add archive jar" to place anything in a runtime
>> classpath. Ideally, during the packaging of a war you'd have something
>> just copy those files where they need to be.
>>
>> As for adding jars - if they're needed for compile, add them through
>> eclipse's build path. To get them recognized for runtime - just manually
>> put them where they need to be.
>>
> 
> ok now i click send (i will only one file), the browser seem to wait....
> 
> eclise return me:
> 
> 
> 
> org.apache.commons.fileupload.FileUploadBase$InvalidContentTypeException: the 
> request doesn't contain a multipart/form-data or multipart/mixed stream, 
> content type header is application/x-www-form-urlencoded
> 	at 
> org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:294)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)

iD8DBQFEE8jbaCoPKRow/gARAtTnAJ9+WMzyqvjpwlqxuqg0+Zfh8nBnmwCg9Qbo
6RbmLCngG2ytlff1FbfsnM4=
=hIfy
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: upload file [FileUpload]

Posted by Marc Collin <co...@laboiteaprog.com>.
Le Vendredi 10 Mars 2006 16:28, Brian K. Wallace a écrit :
> I wouldn't use "add archive jar" to place anything in a runtime
> classpath. Ideally, during the packaging of a war you'd have something
> just copy those files where they need to be.
>
> As for adding jars - if they're needed for compile, add them through
> eclipse's build path. To get them recognized for runtime - just manually
> put them where they need to be.
>

ok now i click send (i will only one file), the browser seem to wait....

eclise return me:



org.apache.commons.fileupload.FileUploadBase$InvalidContentTypeException: the 
request doesn't contain a multipart/form-data or multipart/mixed stream, 
content type header is application/x-www-form-urlencoded
	at 
org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:294)
	at 
org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:116)
	at Upload.doPost(Upload.java:49)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
	at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
	at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at 
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
	at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
	at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
	at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
	at 
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
	at java.lang.Thread.run(Thread.java:534)


-- 
www.laboiteaprog.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: upload file [FileUpload]

Posted by "Brian K. Wallace" <br...@transmorphix.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I wouldn't use "add archive jar" to place anything in a runtime
classpath. Ideally, during the packaging of a war you'd have something
just copy those files where they need to be.

As for adding jars - if they're needed for compile, add them through
eclipse's build path. To get them recognized for runtime - just manually
put them where they need to be.

Marc Collin wrote:
> Le Vendredi 10 Mars 2006 16:17, Brian K. Wallace a écrit :
> 
>> What you didn't specify is whether you run Tomcat inside Eclipse (such
>> that when eclipse shuts down so does Tomcat) or outside (which would
>> require shutting down Tomcat separately). I've rarely come to a
>> situation where I had to restart Eclipse - and never for a Tomcat
>> problem I was having.
> 
> run tomcat inside eclipse
> 
>> Back to the issue: I looked at your layout and see that you extracted
>> the fileupload jar into WEB-INF/lib.
> 
> eclipse do that when i do: add archive jar
> 
>> (I think this was in the "....." 
>> email that I didn't quite get). The WEB-INF/lib directory is for jar
>> files. No need (matter of fact, don't) to extract those jars - the
>> classes won't get picked up. If you feel you need to, classes are picked
>> up from WEB-INF/classes.
>  
> commons-fileupload-1.1.jar is in
> WEB-INF/lib/
> 
>> Also - assuming you just put jars in that directory, or extract to
>> WEB-INF/classes, and get that part working - you'll still have a
>> problem. See
>> http://jakarta.apache.org/commons/fileupload/dependencies.html for the
>> other jar files you'll need for your project (also to be placed in
>> WEB-INF/lib)
> 
> 
> will try to add these jar.....
> 
> need to do it manually or to do something in eclipse?
> 
>> Brian
>>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)

iD8DBQFEEe+UaCoPKRow/gARAusIAKC3WlzzkZuNHa3f2o1ZwZB6WvoCfACfbAFC
phi0nYRhh2q//ToXUkxWGoQ=
=i3oX
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: upload file [FileUpload]

Posted by Marc Collin <co...@laboiteaprog.com>.
Le Vendredi 10 Mars 2006 16:17, Brian K. Wallace a écrit :

>
> What you didn't specify is whether you run Tomcat inside Eclipse (such
> that when eclipse shuts down so does Tomcat) or outside (which would
> require shutting down Tomcat separately). I've rarely come to a
> situation where I had to restart Eclipse - and never for a Tomcat
> problem I was having.

run tomcat inside eclipse

> Back to the issue: I looked at your layout and see that you extracted
> the fileupload jar into WEB-INF/lib.

eclipse do that when i do: add archive jar

> (I think this was in the "....." 
> email that I didn't quite get). The WEB-INF/lib directory is for jar
> files. No need (matter of fact, don't) to extract those jars - the
> classes won't get picked up. If you feel you need to, classes are picked
> up from WEB-INF/classes.
 
commons-fileupload-1.1.jar is in
WEB-INF/lib/

> Also - assuming you just put jars in that directory, or extract to
> WEB-INF/classes, and get that part working - you'll still have a
> problem. See
> http://jakarta.apache.org/commons/fileupload/dependencies.html for the
> other jar files you'll need for your project (also to be placed in
> WEB-INF/lib)


will try to add these jar.....

need to do it manually or to do something in eclipse?

> Brian
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org

-- 
www.laboiteaprog.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: upload file [FileUpload]

Posted by "Brian K. Wallace" <br...@transmorphix.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Marc Collin wrote:
> Le Vendredi 10 Mars 2006 15:57, Brian K. Wallace a écrit :
>> Without knowing your exact configuration, did you restart Tomcat after
>> you put the jars in the right place? Once Tomcat loads an app, the
>> classloading should be done. If you're running from a war, these files
>> should be in the war so Tomcat will extract them properly. If running
>> exploded just having them in the dir will suffice.
> 
> 
> i use eclipse 3.1 java 1.4
> wtp
> tomcat 5
> 
> ya i restarted eclipse
> 
> i put the eclipse project there
> http://www.laboiteaprog.com/log620_lab3.tar.gz
> 

What you didn't specify is whether you run Tomcat inside Eclipse (such
that when eclipse shuts down so does Tomcat) or outside (which would
require shutting down Tomcat separately). I've rarely come to a
situation where I had to restart Eclipse - and never for a Tomcat
problem I was having.

Back to the issue: I looked at your layout and see that you extracted
the fileupload jar into WEB-INF/lib. (I think this was in the "....."
email that I didn't quite get). The WEB-INF/lib directory is for jar
files. No need (matter of fact, don't) to extract those jars - the
classes won't get picked up. If you feel you need to, classes are picked
up from WEB-INF/classes.

Also - assuming you just put jars in that directory, or extract to
WEB-INF/classes, and get that part working - you'll still have a
problem. See
http://jakarta.apache.org/commons/fileupload/dependencies.html for the
other jar files you'll need for your project (also to be placed in
WEB-INF/lib)

Brian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)

iD8DBQFEEeziaCoPKRow/gARApeQAJ49mTIjDubvwI5JD6F5B7Pt4/pSUgCgpPOY
vzGmdNM2wWDZr9amS+csmBs=
=Ne0U
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: upload file [FileUpload]

Posted by Marc Collin <co...@laboiteaprog.com>.
Le Vendredi 10 Mars 2006 15:57, Brian K. Wallace a écrit :
> Without knowing your exact configuration, did you restart Tomcat after
> you put the jars in the right place? Once Tomcat loads an app, the
> classloading should be done. If you're running from a war, these files
> should be in the war so Tomcat will extract them properly. If running
> exploded just having them in the dir will suffice.


i use eclipse 3.1 java 1.4
wtp
tomcat 5

ya i restarted eclipse

i put the eclipse project there
http://www.laboiteaprog.com/log620_lab3.tar.gz

-- 
www.laboiteaprog.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: upload file [FileUpload]

Posted by "Brian K. Wallace" <br...@transmorphix.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Without knowing your exact configuration, did you restart Tomcat after
you put the jars in the right place? Once Tomcat loads an app, the
classloading should be done. If you're running from a war, these files
should be in the war so Tomcat will extract them properly. If running
exploded just having them in the dir will suffice.

Marc Collin wrote:
> Le Vendredi 10 Mars 2006 15:41, Brian K. Wallace a écrit :
>> As a note for mails, please prefix your subject with [FileUpload]
>>
>> Not sure what the results of the "......" were, but Eclipse compile-time
>> and Tomcat runtime are two totally separate concerns. Eclipse needs the
>> jars in the classpath to compile which is one configuration. Tomcat
>> needs them available in WEB-INF/lib of the webapp in order to find them
>> at runtime. (Make sure you address both the fileupload jar as well as
>> its dependencies)
> 
> 
> i copied manually jar file to  WEB-INF/lib and i get the same problem
> 
>> HTH
>> Brian
> 
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)

iD8DBQFEEegiaCoPKRow/gARAqjcAJwLb6ZfNICfjE5J7VD3VKyiAgXAqQCfYbME
g2O54vDtZWw2YiPl2epeX/k=
=Js3l
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org