users@jersey.java.net

Re: [Jersey] Accessing the response object (in standard JSR311)

From: Jan Algermissen <algermissen1971_at_mac.com>
Date: Mon, 05 Oct 2009 19:23:24 +0200

Given that HttpContext is a Jersey 'extension' - how would one access
the response object if not using the ResponseBuilder pattern?

E.g. if I had

        public StreamingOutput getResource(
                         final @Context HttpContext hc, // Jersey
specific class
                        @PathParam("id") String id
                ) {
                return new StreamingOutput() {
                public void write(OutputStream outputStream) {
                         Response resp = hc.getResponse();
                        // do something with response, e.g. set headers

                        PrintWriter out = new PrintWriter(outputStream);
                        out.println("Foo");
                        out.close();
                } };
        }


How could I avoid the Jersey specific class?

Thanks,

Jan

P.S. Is there actually a better list to use for these kinds of
questions? Seems so quiet over here...