Code to generate an XML document from scratch
//---------------------------------------------------------------------------||
// xmlfromscratch.java ||
// ||
// This code generates an XML document from scratch. ||
//---------------------------------------------------------------------------||
// Written 17 February 2000 by Doug Tidwell. ||
//---------------------------------------------------------------------------||
// ||
// (C) Copyright IBM Corp. 1999 All rights reserved. ||
// ||
// US Government Users Restricted Rights Use, duplication or ||
// disclosure restricted by GSA ADP Schedule Contract with IBM Corp. ||
// ||
// The program is provided "as is" without any warranty express or ||
// implied, including the warranty of non-infringement and the implied ||
// warranties of merchantibility and fitness for a particular purpose. ||
// IBM will not be liable for any damages suffered by you as a result ||
// of using the Program. In no event will IBM be liable for any ||
// special, indirect or consequential damages or lost profits even if ||
// IBM has been advised of the possibility of their occurrence. IBM ||
// will not be liable for any third party claims against you. ||
// ||
//---------------------------------------------------------------------------||
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class xmlfromscratch extends HttpServlet
{
public void service(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/xml");
PrintWriter out = response.getWriter();
out.println("<?xml version=\"1.0\"?>");
out.println("<greeting language=\"en_US\">");
out.println(" Hello, World!");
out.println("</greeting>");
}
}
|