import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import org.w3c.dom.*; import org.w3c.dom.html.*; import org.enhydra.xml.io.DOMFormatter; public class HelloManipulation extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); // Some pseudo-dynamic content String username = "Mark Diekhans"; int numMessages = 43; // Create the DOM tree Hello hello = new Hello(); // Set the title, using a standard DOM method hello.setTitle("Hello XMLC!"); // Set the value for "greeting" hello.setTextGreeting("Hello, " + username); // Set the value for "messages" hello.setTextMessages("" + numMessages); try { DOMFormatter formatter = new DOMFormatter(); // can be heavily tweaked formatter.write(hello, out); } catch (IOException e) { e.printStackTrace(); } } }