cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leo Sutic" <leo.su...@inspireinfrastructure.com>
Subject RE: upload problem (WAS: RE: How to use the file uploading mechanism in cocoon)
Date Sat, 17 May 2003 11:50:41 GMT


> -----Original Message-----
> From: Geoff Howard [mailto:cocoon@leverageweb.com] 
>
> > alternatively, you can write the following java code in your sitemap
> > components
> > 
> >   import org.apache.cocoon.servlet.multipart.*;
> > 
> >   ...
> > 
> >   Request request = ObjectModelHelper.getRequest(obj);
> >   if (request instanceof MultipartHttpServletRequest) {
> 
> This will not work, will it?  The ObjectModelHelper will return 
> o.a.c.environment.HttpRequest (implements o.a.c.environment.Request) 
> and therefore this test will always be false, even when the private 
> HttpServletRequest held by o.a.c.environment.HttpRequest is in fact 
> a multipart.  The instanceof test works in 
> HttpRequest.java:108 because 
> it's testing its private member, not itself. 
> 
> This makes the cleanup fail on CocoonServlet:1209.

Does it? Since the instanceof test is done against the object returned
from the requestFactory:

1045:       if (this.enableUploads) {
                request = requestFactory.getServletRequest(req);
            } else {
                request = req;
            }

Which makes request a MultipartHttpServletRequest. So:

1209:           if (request instanceof MultipartHttpServletRequest) {
                    ((MultipartHttpServletRequest) request).cleanup();
                }

Should be invoked properly.

> What about exposing something like boolean isMultiPart()?

What about exposing a dispose() method instead? In a request-response
environment it makes sense to have an explicit disposal point.

/LS



Mime
View raw message