You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Robin Wyles <ro...@robinwyles.com> on 2008/06/16 22:40:02 UTC

MultipartHttpServletRequest in a generator

Hi,

How can I get hold of a MultipartHttpServletRequest in a generator?

If I do this...

final WebApplicationContext parentContext =  
WebAppContextUtils.getCurrentWebApplicationContext();
final ProcessInfoProvider infoProvider = (ProcessInfoProvider)  
parentContext.getBean(ProcessInfoProvider.ROLE);
HttpServletRequest request = infoProvider.getRequest();
MultipartHttpServletRequest mpr = (MultipartHttpServletRequest) request;

I get the following error when the final line is executed...

java.lang.ClassCastException: $Proxy13

Eclipse debugger shows that request is an instance of  
MultipartHttpServletRequest.

What's the secret?

Cheers,

Robin

Re: MultipartHttpServletRequest in a generator

Posted by Joerg Heinicke <jo...@gmx.de>.
On 16.06.2008 23:10, Grzegorz Kossakowski wrote:

> Situations like this are little bit worrying me but anyway standard 
> question: why do you want to cast to MultipartHttpServletRequest?

MultipartHttpServletRequest provides a method get(String) for access to 
multiparts which can't be accessed in another way. This method is not 
available from an interface.

Is this proxy castable to org.springframework.aop.scope.ScopedObject? 
Then you would be able to call getTargetObject() and so get access to 
the actual MultipartHttpServletRequest object.

Joerg

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


Re: MultipartHttpServletRequest in a generator

Posted by Robin Wyles <ro...@robinwyles.com>.
Grzegorz,

How's this:

1. Multipart request is received, its parts (some binary, some XML)  
need to be extracted and processed varyingly.

2. Suitable response XML and response code should be be returned.

Based on these requirements and my slowly but ever expanding  
knowledge of cocoon, I would've thought a generator would be the  
correct component to handle that...

All I'm really having trouble with is getting the parts out of the  
incoming request.

Robin



On 16 Jun 2008, at 22:26, Grzegorz Kossakowski wrote:

> Robin Wyles pisze:
>> By the way you asked, I guess in some sort of ridiculous attempt  
>> to get hold of some binary data that has been posted to a pipeline  
>> containing the generator :)
>
> Robin, not sure if I understood you correctly but probably that's  
> another sign of /bad/ approach. ;-)
> Good approaches are good because they can explained to someone else  
> easily.
>
>
> --
> Grzegorz Kossakowski
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


Re: MultipartHttpServletRequest in a generator

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Robin Wyles pisze:
> By the way you asked, I guess in some sort of ridiculous attempt to get 
> hold of some binary data that has been posted to a pipeline containing 
> the generator :)

Robin, not sure if I understood you correctly but probably that's another sign of /bad/ approach. ;-)
Good approaches are good because they can explained to someone else easily.


--
Grzegorz Kossakowski

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


Re: MultipartHttpServletRequest in a generator

Posted by Robin Wyles <ro...@robinwyles.com>.
By the way you asked, I guess in some sort of ridiculous attempt to  
get hold of some binary data that has been posted to a pipeline  
containing the generator :)


robin


On 16 Jun 2008, at 22:10, Grzegorz Kossakowski wrote:

> Robin Wyles pisze:
>> Hi,
>> How can I get hold of a MultipartHttpServletRequest in a generator?
>> If I do this...
>> final WebApplicationContext parentContext =  
>> WebAppContextUtils.getCurrentWebApplicationContext();
>> final ProcessInfoProvider infoProvider = (ProcessInfoProvider)  
>> parentContext.getBean(ProcessInfoProvider.ROLE);
>> HttpServletRequest request = infoProvider.getRequest();
>> MultipartHttpServletRequest mpr = (MultipartHttpServletRequest)  
>> request;
>> I get the following error when the final line is executed...
>> java.lang.ClassCastException: $Proxy13
>> Eclipse debugger shows that request is an instance of  
>> MultipartHttpServletRequest.
>> What's the secret?
>
> The secret is how JVM proxies work with the fact that  
> MultipartHttpServletRequest is a class not interface.
>
> Situations like this are little bit worrying me but anyway standard  
> question: why do you want to cast to MultipartHttpServletRequest?
>
> -- 
> Grzegorz Kossakowski
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


Re: MultipartHttpServletRequest in a generator

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Robin Wyles pisze:
> Hi,
> 
> How can I get hold of a MultipartHttpServletRequest in a generator?
> 
> If I do this...
> 
> final WebApplicationContext parentContext = 
> WebAppContextUtils.getCurrentWebApplicationContext();
> final ProcessInfoProvider infoProvider = (ProcessInfoProvider) 
> parentContext.getBean(ProcessInfoProvider.ROLE);
> HttpServletRequest request = infoProvider.getRequest();
> MultipartHttpServletRequest mpr = (MultipartHttpServletRequest) request;
> 
> I get the following error when the final line is executed...
> 
> java.lang.ClassCastException: $Proxy13
> 
> Eclipse debugger shows that request is an instance of 
> MultipartHttpServletRequest.
> 
> What's the secret?

The secret is how JVM proxies work with the fact that MultipartHttpServletRequest is a class not 
interface.

Situations like this are little bit worrying me but anyway standard question: why do you want to 
cast to MultipartHttpServletRequest?

-- 
Grzegorz Kossakowski

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