users@jersey.java.net

Re: [Jersey] entities encoding issues in the response

From: Tatu Saloranta <cowtowncoder_at_yahoo.com>
Date: Mon, 19 May 2008 12:27:56 -0700 (PDT)

--- Arul Dhesiaseelan <arul_at_fluxcorp.com> wrote:

> Tatu,
>
> I have the CDATA set in my resource class.

Ouch. This does indeed look wrong. Below does not make
sense -- you should never ever try to hand-generate
xml this way:

...
> StringBuilder().append("<![CDATA[<div
> class=\"progressOuterRow\"><div
> class=\"progressInnerRow\"
> style=\"width:
>
").append(result.toString()).append("px;\"></div><div
>
>
class=\"progressText\">").append(used).append("/").append(total).append("

...

> I assume this CDATA will be sent as a string to the
> XMLStreamWriter.writeCharacters() when the
> MessageBodyWriter<CellType>
> is invoked.

Yes. And that's where double-escaping comes from.
Input has to be textual serialization; or
alternatively, write methods would have to parser and
re-serialize contents. But that sounds wrong
conceptually.

-+ Tatu +-