users@jersey.java.net

[Jersey] Re: Response headers gets removed using HttpContext

From: Jose Antonio Illescas Del Olmo <jantonio.illescas_at_rbcdexia-is.es>
Date: Mon, 08 Aug 2011 11:01:25 +0200

You are right an annotation to set reponse codes is the best solution...


I think about this and I have a solution..., use Guice and Servlet Filters:


1.- create a custom annotation @ResponseHeader(name="", value="") => any
(custom) annotation is valid
2.- guice can intercept al methods annotated with: @GET, @POST, @PUT and
@DELETE and sets, in ThreadLocal, all @ResponseHeaders => we can store
any (custom) annotation on threadLocal
4.- a servlet Filter check react to ThreadLocal value => for example to
move all ResponseHeaders to real HttpServletResponse


I try to do and post my code when finished :

    This solution allows Custom Handlers (custom pre/post process),
Logs, Redirects, ... *and any custom process based on (custom)
annotations !!*



On 05/08/2011 19:22, charlesk wrote:
> Better question may be that using HttpContext injection to set response
> headers is currently supported?
> If so, in which stage of an application that we should do this? Is there
> any sample code/examples I can look into?
> Thanks so much.
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/Response-headers-gets-removed-using-HttpContext-tp6650678p6657337.html
> Sent from the Jersey mailing list archive at Nabble.com.
>