user289463
user289463

Reputation: 2814

GAE Servlet XML Response. How?

I need to send XML response from my GAE servlet. What I already have is: - An instance of org.w3c.dom.Document populated with data - HttpServletResponse (that gives me either a PrintWriter or a ServletOutputStream)

If XMLSerializer were whitelisted in GAE, I could finish the work. ..but it's not.

My question is: How to cook the food from these ingredients? (without 3rd party libraries please)

Thanks for any hints.

Upvotes: 0

Views: 339

Answers (1)

Steven
Steven

Reputation: 3894

Have you tried:

Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, ENCODING);
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", INDENT);
StreamResult result = new StreamResult(writer);
DOMSource source = new DOMSource(document);
transformer.transform(source, result);

Upvotes: 1

Related Questions