Re: Trouble with programatically-added servlet and @MultipartConfig [solved]
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 All, When working with multipart/form-data, remember to follow all the rules: * Request's Content-Length should include all the content (I had that) * Boundary is required as part of the Content-Type (I had that, too) * Boundary separates each of the parts (I had that) * Each boundary is prepended with "--" (I didn't have that) * The final boundary is postpended with "--" (I didn't have that, either) Here is an example of a *proper* multipart/form-data request: POST http://localhost:8007/regular HTTP/1.1 Host: localhost Connection: close Content-Type: multipart/form-data; boundary=--simpleboundary Content-Length: 96 - simpleboundary Content-Disposition: form-data; name="name" value - simpleboundary-- Note the additional leading "--" for all boundaries and the trailing "--" for the last one. All is well, now. Thanks, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk05rA4ACgkQ9CaO5/Lv0PCvCwCeJOc5tTorIjdypMBWh2B7jBNZ vDgAmQHqFhYrUdFOApGLaxyRZb4bQio6 =iVVP -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Trouble with programatically-added servlet and @MultipartConfig
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Mark, On 1/21/2011 5:55 AM, Mark Thomas wrote: > On 20/01/2011 23:43, Christopher Schultz wrote: >> A'ight. It may be ignoring non-file parts. I'll look into that. > > o.a.catalina.connector.Request.getParts() Yeah, I was already poking around in there. >> If it *is* ignoring non-file parts, it seems like a bug to me. > > It isn't. You're right: I decided to stand-up a real TC7 instance, deploy my servlet into it and have a real web browser submit to it. It seems that my multipart request is also broken in some way, because Tomcat correctly returns parts=1 (the multipart part count from my test request), AND reports that there is 1 parameter available from the parameter map. >> TC may be merging non-file parts back into the parameters map, which >> sounds convenient but might be surprising to a servlet author. > > Only if they haven't read section 3.2 of the Servlet 3.0 specification. ...which I have since read :) Thanks, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk05ojcACgkQ9CaO5/Lv0PASPwCgsr8PyEvLG0GMBk1u+9+IiFgq klAAnRgR95vS2txtYWh+XgnxVug3t1WL =EFND -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Trouble with programatically-added servlet and @MultipartConfig
On 20/01/2011 23:43, Christopher Schultz wrote: > Mark, > > On 1/20/2011 6:27 PM, Mark Thomas wrote: >> On 20/01/2011 23:23, Christopher Schultz wrote: >>> I happen, for the sake of simplicity, to be using a non-file multipart >>> part. Could that be confusing things? > >> It may well be. The parts are expected to be files (AFAICR). > >> The code is just a package renamed import of Commons File Upload with a >> thin wrapper around it to map it to the servlet API. > > A'ight. It may be ignoring non-file parts. I'll look into that. o.a.catalina.connector.Request.getParts() > If it *is* ignoring non-file parts, it seems like a bug to me. It isn't. > TC may be merging non-file parts back into the parameters map, which > sounds convenient but might be surprising to a servlet author. Only if they haven't read section 3.2 of the Servlet 3.0 specification. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Trouble with programatically-added servlet and @MultipartConfig
Christopher Schultz wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Mark, On 1/20/2011 6:27 PM, Mark Thomas wrote: On 20/01/2011 23:23, Christopher Schultz wrote: I happen, for the sake of simplicity, to be using a non-file multipart part. Could that be confusing things? It may well be. The parts are expected to be files (AFAICR). The code is just a package renamed import of Commons File Upload with a thin wrapper around it to map it to the servlet API. A'ight. It may be ignoring non-file parts. I'll look into that. If it *is* ignoring non-file parts, it seems like a bug to me. It should not. I'm pretty sure that I used it before, for parsing POST's from enctype="multipart/form-data"> forms, including uploaded items, but also normal text fields. See here : http://commons.apache.org/fileupload/using.html Processing the uploaded items It is very neat, and if browsers correctly labeled the parts with a "Content-type" header including a charset (as they are supposed to do), it would get rid of most of these silly character set issues in posted forms (and in decoding them at the server level). Unfortunately, browsers don't. But if you were writing your own client.. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Trouble with programatically-added servlet and @MultipartConfig
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Mark, On 1/20/2011 6:27 PM, Mark Thomas wrote: > On 20/01/2011 23:23, Christopher Schultz wrote: >> I happen, for the sake of simplicity, to be using a non-file multipart >> part. Could that be confusing things? > > It may well be. The parts are expected to be files (AFAICR). > > The code is just a package renamed import of Commons File Upload with a > thin wrapper around it to map it to the servlet API. A'ight. It may be ignoring non-file parts. I'll look into that. If it *is* ignoring non-file parts, it seems like a bug to me. TC may be merging non-file parts back into the parameters map, which sounds convenient but might be surprising to a servlet author. Thanks, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk04yK4ACgkQ9CaO5/Lv0PD+vwCgnE2ZOylL8SO31st2NMgc1fbu WoQAoMApcFH7UTKfCMf/IC8ddKufpWiP =e0X4 -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Trouble with programatically-added servlet and @MultipartConfig
On 20/01/2011 23:23, Christopher Schultz wrote: > Mark, > > On 1/20/2011 5:24 PM, Mark Thomas wrote: >> On 20/01/2011 22:10, Christopher Schultz wrote: >>> All, >>> >>> I'm working on a patch for allowing multipart parsing when a servlet >>> doesn't have the @MultipartConfig annotation but I'm having trouble >>> testing the case where the servlet *does* have the annotation. > >> And the winner is... > >>> 2. Tomcat doesn't scan for @MultipartConfig when programmatically >>> registering servlets (does it?) > >> at least not when using the embedded interface like that it doesn't. > >> You need to do something like: > >> Wrapper w = Tomcat.addServlet(...) >> w.setsetMultipartConfigElement(...) > > Thanks, but I'm still not getting the part I expect. :( > > I'm starting to dig down into the code for FileUploadBase and friends > but maybe you can help me short-circuit a bit: does getParts only return > multipart/form-data parts that are actually file uploads? The javadoc > doesn't say anything except that all parts are available via the > getParts method. > > I happen, for the sake of simplicity, to be using a non-file multipart > part. Could that be confusing things? It may well be. The parts are expected to be files (AFAICR). The code is just a package renamed import of Commons File Upload with a thin wrapper around it to map it to the servlet API. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Trouble with programatically-added servlet and @MultipartConfig
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Mark, On 1/20/2011 5:24 PM, Mark Thomas wrote: > On 20/01/2011 22:10, Christopher Schultz wrote: >> All, >> >> I'm working on a patch for allowing multipart parsing when a servlet >> doesn't have the @MultipartConfig annotation but I'm having trouble >> testing the case where the servlet *does* have the annotation. > > And the winner is... > >> 2. Tomcat doesn't scan for @MultipartConfig when programmatically >> registering servlets (does it?) > > at least not when using the embedded interface like that it doesn't. > > You need to do something like: > > Wrapper w = Tomcat.addServlet(...) > w.setsetMultipartConfigElement(...) Thanks, but I'm still not getting the part I expect. :( I'm starting to dig down into the code for FileUploadBase and friends but maybe you can help me short-circuit a bit: does getParts only return multipart/form-data parts that are actually file uploads? The javadoc doesn't say anything except that all parts are available via the getParts method. I happen, for the sake of simplicity, to be using a non-file multipart part. Could that be confusing things? Thanks, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk04w/gACgkQ9CaO5/Lv0PBJZACdECTLQmcjKcOL75YPsd/O3HuO rWUAnjHs5V4lHH9ITiYsMN6BEHlzv0Ze =EEKt -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Trouble with programatically-added servlet and @MultipartConfig
On 20/01/2011 22:10, Christopher Schultz wrote: > All, > > I'm working on a patch for allowing multipart parsing when a servlet > doesn't have the @MultipartConfig annotation but I'm having trouble > testing the case where the servlet *does* have the annotation. And the winner is... > 2. Tomcat doesn't scan for @MultipartConfig when programmatically > registering servlets (does it?) at least not when using the embedded interface like that it doesn't. You need to do something like: Wrapper w = Tomcat.addServlet(...) w.setsetMultipartConfigElement(...) Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org