FileObject webXmlFo = dir.getFileObject("web/WEB-INF/web.xml");
WebApp webApp = DDProvider.getDefault().getDDRoot(webXmlFo);
DataObject webXmlDo = DataObject.find(webXmlFo);
try {
Servlet servlet = (Servlet) webApp.createBean("Servlet");
servlet.setServletName(name);
servlet.setServletClass("wicket.protocol.http.WicketServlet");
ServletMapping mapping = (ServletMapping) webApp.createBean("ServletMapping");
mapping.setServletName(name);
mapping.setUrlPattern("/"+name+"/\*");
WelcomeFileList welcomefilelist = (WelcomeFileList) webApp.createBean("WelcomeFileList");
welcomefilelist.addWelcomeFile("index.html");
webApp.setWelcomeFileList(welcomefilelist);
webApp.addServlet(servlet);
webApp.addServletMapping(mapping);
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
webApp.write(webXmlFo);
OpenCookie open = (OpenCookie) webXmlDo.getCookie(OpenCookie.class);
if (open != null) {
open.open();
}
By the way, the data object is only there so that the OpenCookie can be used. For details on data objects, see the NetBeans DataLoader Module Tutorial. My shortcut understanding of data objects vs. file objects is that data objects are higher up in the evolutionary chain and can therefore "do" more things, such as consume cookies without breaking teeth...