You can use a JSP to generate HTML or XML, … setting the content type of the JSP cannot be done in your servlet using request.setContentType() method, however. Instead, you must use the JSP content type directive. For example, to set the content type to text/xml, include the following line in your JSP.
<%@ page contentType="text/xml" %>
Advertisement