You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Ivan <xh...@gmail.com> on 2010/05/13 04:00:10 UTC

getPart()/getParts() invocation in the filter ?

Hi,
    While using the new features of getPart()/getParts() in the Servlet 3.0,
I found that those methods could not be invoked in filter.
    After checking the spec, I found some words below :
    --->
    File upload
     If a request is of type multipart/form-data and if the servlet handling
the
     request is annotated using the @MultipartConfig as defined in Section
8.1.5,
     "@MultipartConfig" on page 8-64, the HttpServletRequest can make
available
     the various parts of the multipart request via the following methods
    ■ public Collection<Part> getParts()
    ■ public Part getPart(String name).
    <---
    --->
    @MultipartConfig
     This annotation, when specified on a Servlet, indicates that the
request it expects
     is of type mime/multipart. The HttpServletRequest object of the
     corresponding servlet MUST make available the mime attachments via the
     getParts and getPart methods to iterate over the various mime
attachments.
    <---
     I am just wondering that :
     a. Are those two methods available when the request is of
multipart/form-data type AND the servlet handlering it are configured with
MultipartConfig (annotation or configurations in web.xml) ? Why not make
those methods avaible once it detects the multipart/form-data type ?
     b. Are those two methods only available in Servlet ? Seems that the
spec expects the users handle the uploading in Servlet ?
     Thanks !
-- 
Ivan

Re: getPart()/getParts() invocation in the filter ?

Posted by Ivan <xh...@gmail.com>.
Thanks, Mark !

2010/5/13 Mark Thomas <ma...@apache.org>

> On 13/05/2010 15:43, Ivan wrote:
>
>> Thanks, Mark.
>> OK,  turn to the user mail list.
>>  From the text I quoted from servlet spec, does it mean that I must
>> configured the target servlet with multipart (annotation or web.xml), or
>> those two getPart()/getParts() methods could not be used even the incoming
>> request is of mutlipart type?  Actually, I tried in the latest Tomcat 7,
>> it
>> seems to work in this way.
>>
>
> Correct. You *must* define the servlet as multipart in order to use the
> getPart()/getParts() methods.
>
> Mark
>
>
>
>> 2010/5/13 Mark Thomas<ma...@apache.org>
>>
>>  On 13/05/2010 03:00, Ivan wrote:
>>>
>>>  Hi,
>>>>     While using the new features of getPart()/getParts() in the Servlet
>>>> 3.0,
>>>> I found that those methods could not be invoked in filter.
>>>>
>>>>
>>> The short answer is that this should work, even from a filter.
>>>
>>> The long answer is that this discussion belongs on the users list for
>>> now.
>>> If that discussion identifies a bug in the current Tomcat implementation
>>> then any discussion around fixing that belongs here.
>>>
>>> Mar
>>>
>>>
>>>      After checking the spec, I found some words below :
>>>
>>>>     --->
>>>>     File upload
>>>>      If a request is of type multipart/form-data and if the servlet
>>>> handling
>>>> the
>>>>      request is annotated using the @MultipartConfig as defined in
>>>> Section
>>>> 8.1.5,
>>>>      "@MultipartConfig" on page 8-64, the HttpServletRequest can make
>>>> available
>>>>      the various parts of the multipart request via the following
>>>> methods
>>>>     ■ public Collection<Part>   getParts()
>>>>     ■ public Part getPart(String name).
>>>>     <---
>>>>     --->
>>>>     @MultipartConfig
>>>>      This annotation, when specified on a Servlet, indicates that the
>>>> request it expects
>>>>      is of type mime/multipart. The HttpServletRequest object of the
>>>>      corresponding servlet MUST make available the mime attachments via
>>>> the
>>>>      getParts and getPart methods to iterate over the various mime
>>>> attachments.
>>>>     <---
>>>>      I am just wondering that :
>>>>      a. Are those two methods available when the request is of
>>>> multipart/form-data type AND the servlet handlering it are configured
>>>> with
>>>> MultipartConfig (annotation or configurations in web.xml) ? Why not make
>>>> those methods avaible once it detects the multipart/form-data type ?
>>>>      b. Are those two methods only available in Servlet ? Seems that the
>>>> spec expects the users handle the uploading in Servlet ?
>>>>      Thanks !
>>>>
>>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>>
>>>
>>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
Ivan

Re: getPart()/getParts() invocation in the filter ?

Posted by Mark Thomas <ma...@apache.org>.
On 13/05/2010 15:43, Ivan wrote:
> Thanks, Mark.
> OK,  turn to the user mail list.
>  From the text I quoted from servlet spec, does it mean that I must
> configured the target servlet with multipart (annotation or web.xml), or
> those two getPart()/getParts() methods could not be used even the incoming
> request is of mutlipart type?  Actually, I tried in the latest Tomcat 7, it
> seems to work in this way.

Correct. You *must* define the servlet as multipart in order to use the 
getPart()/getParts() methods.

Mark

>
> 2010/5/13 Mark Thomas<ma...@apache.org>
>
>> On 13/05/2010 03:00, Ivan wrote:
>>
>>> Hi,
>>>      While using the new features of getPart()/getParts() in the Servlet
>>> 3.0,
>>> I found that those methods could not be invoked in filter.
>>>
>>
>> The short answer is that this should work, even from a filter.
>>
>> The long answer is that this discussion belongs on the users list for now.
>> If that discussion identifies a bug in the current Tomcat implementation
>> then any discussion around fixing that belongs here.
>>
>> Mar
>>
>>
>>       After checking the spec, I found some words below :
>>>      --->
>>>      File upload
>>>       If a request is of type multipart/form-data and if the servlet
>>> handling
>>> the
>>>       request is annotated using the @MultipartConfig as defined in Section
>>> 8.1.5,
>>>       "@MultipartConfig" on page 8-64, the HttpServletRequest can make
>>> available
>>>       the various parts of the multipart request via the following methods
>>>      ■ public Collection<Part>   getParts()
>>>      ■ public Part getPart(String name).
>>>      <---
>>>      --->
>>>      @MultipartConfig
>>>       This annotation, when specified on a Servlet, indicates that the
>>> request it expects
>>>       is of type mime/multipart. The HttpServletRequest object of the
>>>       corresponding servlet MUST make available the mime attachments via
>>> the
>>>       getParts and getPart methods to iterate over the various mime
>>> attachments.
>>>      <---
>>>       I am just wondering that :
>>>       a. Are those two methods available when the request is of
>>> multipart/form-data type AND the servlet handlering it are configured with
>>> MultipartConfig (annotation or configurations in web.xml) ? Why not make
>>> those methods avaible once it detects the multipart/form-data type ?
>>>       b. Are those two methods only available in Servlet ? Seems that the
>>> spec expects the users handle the uploading in Servlet ?
>>>       Thanks !
>>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
>>
>
>




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: getPart()/getParts() invocation in the filter ?

Posted by Ivan <xh...@gmail.com>.
Thanks, Mark.
OK,  turn to the user mail list.
>From the text I quoted from servlet spec, does it mean that I must
configured the target servlet with multipart (annotation or web.xml), or
those two getPart()/getParts() methods could not be used even the incoming
request is of mutlipart type?  Actually, I tried in the latest Tomcat 7, it
seems to work in this way.

2010/5/13 Mark Thomas <ma...@apache.org>

> On 13/05/2010 03:00, Ivan wrote:
>
>> Hi,
>>     While using the new features of getPart()/getParts() in the Servlet
>> 3.0,
>> I found that those methods could not be invoked in filter.
>>
>
> The short answer is that this should work, even from a filter.
>
> The long answer is that this discussion belongs on the users list for now.
> If that discussion identifies a bug in the current Tomcat implementation
> then any discussion around fixing that belongs here.
>
> Mar
>
>
>      After checking the spec, I found some words below :
>>     --->
>>     File upload
>>      If a request is of type multipart/form-data and if the servlet
>> handling
>> the
>>      request is annotated using the @MultipartConfig as defined in Section
>> 8.1.5,
>>      "@MultipartConfig" on page 8-64, the HttpServletRequest can make
>> available
>>      the various parts of the multipart request via the following methods
>>     ■ public Collection<Part>  getParts()
>>     ■ public Part getPart(String name).
>>     <---
>>     --->
>>     @MultipartConfig
>>      This annotation, when specified on a Servlet, indicates that the
>> request it expects
>>      is of type mime/multipart. The HttpServletRequest object of the
>>      corresponding servlet MUST make available the mime attachments via
>> the
>>      getParts and getPart methods to iterate over the various mime
>> attachments.
>>     <---
>>      I am just wondering that :
>>      a. Are those two methods available when the request is of
>> multipart/form-data type AND the servlet handlering it are configured with
>> MultipartConfig (annotation or configurations in web.xml) ? Why not make
>> those methods avaible once it detects the multipart/form-data type ?
>>      b. Are those two methods only available in Servlet ? Seems that the
>> spec expects the users handle the uploading in Servlet ?
>>      Thanks !
>>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>


-- 
Ivan

Re: getPart()/getParts() invocation in the filter ?

Posted by Mark Thomas <ma...@apache.org>.
On 13/05/2010 03:00, Ivan wrote:
> Hi,
>      While using the new features of getPart()/getParts() in the Servlet 3.0,
> I found that those methods could not be invoked in filter.

The short answer is that this should work, even from a filter.

The long answer is that this discussion belongs on the users list for 
now. If that discussion identifies a bug in the current Tomcat 
implementation then any discussion around fixing that belongs here.

Mar

>      After checking the spec, I found some words below :
>      --->
>      File upload
>       If a request is of type multipart/form-data and if the servlet handling
> the
>       request is annotated using the @MultipartConfig as defined in Section
> 8.1.5,
>       "@MultipartConfig" on page 8-64, the HttpServletRequest can make
> available
>       the various parts of the multipart request via the following methods
>      ■ public Collection<Part>  getParts()
>      ■ public Part getPart(String name).
>      <---
>      --->
>      @MultipartConfig
>       This annotation, when specified on a Servlet, indicates that the
> request it expects
>       is of type mime/multipart. The HttpServletRequest object of the
>       corresponding servlet MUST make available the mime attachments via the
>       getParts and getPart methods to iterate over the various mime
> attachments.
>      <---
>       I am just wondering that :
>       a. Are those two methods available when the request is of
> multipart/form-data type AND the servlet handlering it are configured with
> MultipartConfig (annotation or configurations in web.xml) ? Why not make
> those methods avaible once it detects the multipart/form-data type ?
>       b. Are those two methods only available in Servlet ? Seems that the
> spec expects the users handle the uploading in Servlet ?
>       Thanks !




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org