JSP RESPONSE: <%@ page contentType="text/xml;charset=ISO-8859-1"%> // Write the XML in JSP file.
SERVLET RESPONSE: response.setContentType("text/xml;charset=ISO-8859-1"); // Print the XML in the response object.
NOTE: 1. Both the above approaches display the XML in the browser. 2. You can even generate dynamic content (say, bring data from backend and display in XML), the way you do normally. 3. If you want the XML to download as a document, you would have to send it as a response attachment.