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: Fri, 05 Aug 2011 18:45:11 +0200

Charlesk, I see your alternatives, but I like a simple alternative to
programatic redirects (based on new String parameter on @POST, @PUT and
@DELETE)

   @POST("redirect-to-this url")

One question: Are necesary multiples redirects for distinct mediatypes?

    @POST("test/html:/redirect1","text/xml:/redirect2")

I think that redirects are necesary only on user-to-computer interaction
with browsers ("text/html"), please note that (X)HTML is the "only"
format that allows POST/PUT/DELETE submits from browsers)

   Users with another HTTP clients (stand-alone), not browser-based, not
requires redirection (client navigation is stored on client)

   Program-client do not require redirection: only requiere the response
result: OK/ERROR (or HTTP status) and response content: body

Regards

On 05/08/2011 18:01, charlesk wrote:
> I'm adding the headers in my complete method below and I think as you have
> mentioned that Response.ok should work, using the injected HttContext should
> work as well. Btw, this used to work with HttpServletRequest injection (i.e
> HttpServletRequest.setHeader("Content-Location", uri.toString());)
> Thanks.
>
>
> @GET
> @Produces({"application/xml;charset=UTF-8",
> "application/json;charset=UTF-8", "application/javascript"})
> public HelloWorld sayHello() {
> return complete(new HelloWorld());
> }
>
> @GET
> @Produces({"application/xml;charset=UTF-8",
> "application/json;charset=UTF-8", "application/javascript"})
> public HelloWorld sayHello() {
> return Response.ok().entity(entity).header("myHeader", "value").build();
> }
>
>
> @Context private HttpContext _context;
> protected<ElementType extends RootYahooElement> ElementType
> complete(ElementType element)
> {
> if(_context.getResponse() != null) {
>
> _context.getResponse().getHttpHeaders().putSingle("Content-Location",
> uri.toString());
>
> _context.getResponse().getHttpHeaders().putSingle("Content-Language",
> element.getLang());
>
> }
> return element;
> }
>
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/Response-headers-gets-removed-using-HttpContext-tp6650678p6657069.html
> Sent from the Jersey mailing list archive at Nabble.com.
>