users@jersey.java.net

Re: [Jersey] File upload multipart/form-data issue with Struts2-Spring

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 10 Feb 2009 11:22:31 +0100

On Feb 9, 2009, at 5:57 PM, coldserenity wrote:

>
>
> coldserenity wrote:
>>
>> I'm using jersey-multipart-1.0.2-SNAPSHOT. Application is running on
>> jboss-4.2.2.GA, struts2, spring
>>
>> I've tried this example out of our Struts2-Spring environment and
>> everything worked fine.
>> Does anyone have an idea what could be the reason for this?
>>
>
> It looks like the problem with Struts out-of-the-box behavior
>
> fileupload-faq wrote:
>>
>> Struts recognises multipart requests, and parses them automatically,
>> presenting the request parameters to your code in the same manner
>> as if
>> they were regular request parameters. Since Struts has already
>> processed
>> the request, and made it available in your form bean, the input
>> stream is
>> no longer available for parsing, so attempting to do so with
>> FileUpload
>> will fail.
>> (from here:
>> http://commons.apache.org/fileupload/faq.html#parse-in-action-fails
>> http://commons.apache.org/fileupload/faq.html#parse-in-action-fails )
>
> Currently looking for a way to exclude a certain path from Struts
> filter
> processing (which is also a tricky task). If someone had similar
> "challenges" configuring Jersey, ideas are appreciated.

I wonder if it possible to do the following, which may cause other
issues. Place a filter before the struts filter to modify the content
type of the request to something else. Place a filter after the struts
filter to modify the content type back to its original value.

Paul.