cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven Dolg <steven.d...@indoqa.com>
Subject Re: [cocoon3] @Context Request request
Date Mon, 31 Oct 2011 09:44:23 GMT
Am 30.10.2011 18:35, schrieb Andre Juffer:
> Hi,
>
> for processing a multipart/form-data request holding image data, I 
> intend to use the commons imageupload [1]. In order to do so, I need 
> to get access to the javax.servlet.http.HttpServletRequest object 
> inside a REST resource. The @Context annotation injects information 
> about the request, see e.g. [2] and also [3], but the request object 
> should implement the javax.ws.rs.core.Request interface (I think).
>
> How can I get to the HttpServletRequest inside a REST resource. Is 
> there a way to convert Request to 
> javax.servlet.http.HttpServletRequest? According to [4],"When 
> deploying a JAX-RS application using servlet then ServletConfig, 
> ServletContext, HttpServletRequest and HttpServletResponse are 
> available using @Context." But how?
>
> Right now, I assume
>
> @POST
> public Response uploadImage(@Context HttpServletRequest request) {
> .....
> }
>
> but I do not believe this is actually correct.
>
> The actual type is com.sun.jersey.spi.container.ContainerRequest 
> (implements Request), according to request.getClass().getName().
>
> There is nothing in the request itself, while I see with Firebug that 
> the image file is sent to the server in the proper way.

Hi André,

the code fragment you posted appears to be correct and conform with 
Jersey - the JAX-RS implementation used by Cocoon 3.

If you receive a value in the parameter request, then it will be of type 
HttpServletRequest. The JVM won't allow anything else.
Of course you receive an actual implementation, since HttpServletRequest 
is only an interface.

So the question is:
What do you want to do with the request and why do you believe it is not 
working correctly?

Cheers,
Steven

>
> Thanks,
> André
>
>
> [1] http://commons.apache.org/fileupload/index.html
> [2] http://cocoon.apache.org/3.0/reference/html/webapps.html
> [3] 
> http://jsr311.java.net/nonav/releases/1.1/javax/ws/rs/core/Context.html
> [4] http://jersey.java.net/nonav/documentation/latest/jax-rs.html#d4e524
>
>


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


Mime
View raw message