开发者

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.


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜