How to Send XML as Response
You can use practially any XML API to create XML, just set the content type correctly and write the XML to the OuputStream. Alternatively you can also use a JSP to create the XML, which can sometimes be more convenient.
The following example shows you how to send XML with the JAXB API:
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException {
MovieLibrary library = ...; // example tree from the JAXB Guide
response.setContentType("text/xml"); // generic XML content type (more)
JAXB.marshal(library, response.getOutputStream()); // write XML with JAXB
}

