users@jersey.java.net

[Jersey] Re: Need to modify the response entity / stream after marshalling happened

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Tue, 01 Nov 2011 17:11:59 +0100

Hi Han,

You should be able to implement your own message body writer
which would produce transformed output.

The new provider could delegate XML marshaling to existing
JAXB message body writers (see [1] on how you can get them injected)
and only take care of the transformation using e.g. javax.xml.transform
API (see [2]).

HTH,

~Jakub

[1]http://jsr311.java.net/nonav/releases/1.1/javax/ws/rs/ext/Providers.html
[2]http://download.oracle.com/javase/6/docs/api/javax/xml/transform/package-summary.html


On 29.10.2011 3:08, DaHoopster wrote:
> I am working on a project that I need such a filter or mechanism to modify
> the XML marshalled by the message body writer before returning to the
> client.
>
> I need to apply a XSLT on the XML for several resources. It looks like
> ContainerResponseFilter is not suitable for the job since it is invoked
> before marshalling.
>
> Is there a way to achieve this via Jersey? I am using Jersey 1.6
>
> Regards,
> Han
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/Need-to-modify-the-response-entity-stream-after-marshalling-happened-tp6942294p6942294.html
> Sent from the Jersey mailing list archive at Nabble.com.
>