This will make some simple changes to the descriptor and write it back
out to a new file.
// Change the encoding
webApp.setOutputEncoding("ISO-8859-1");
// Change the DTD to a local version
webApp.setDocType("web-app", null, "dtds/sun/web-app_2_2.dtd");
// Modify the display name
webApp.setDisplayName(webApp.getDisplayName() +
" [Modified by WebAppDisplayer]");
// Add a new servlet
Servlet servlet = new ServletImpl();
servlet.setServletName("WelcomeServlet");
servlet.setServletClass("javajaxb.servlet.WelcomeServlet");
webApp.addServlet(servlet);
// marshal
webApp.marshal(outputFile);