[jdom-interest] addElement position
Paul Kuzan
paul_kuzan at hotmail.com
Mon Apr 1 11:15:23 PST 2002
I'm trying to add a <servlet-mapping> element to a web.xml file.
When I add the new Element, it is placed as the last Element which violates
the DTD.
How can I control the placement of the new Element or move it so the XML
conforms to the DTD?
I'm using the code below.
Many thanks,
Paul
Element servletMappingElement = new Element("servlet-mapping");
//Add child Elements
rootElement.addContent(servletMappingElement);
*******************What I get*******************
<web-app>
<display-name>Web_Application</display-name>
<servlet>
<servlet-name>Foo</servlet-name>
<servlet-class>bar</servlet-class>
</servlet>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<servlet-mapping>
<servlet-name>Foo</servlet-name>
<servlet-mapping>*.do</servlet-mapping>
</servlet-mapping>
</web-app>
*******************What I want*******************
<web-app>
<display-name>Web_Application</display-name>
<servlet>
<servlet-name>Foo</servlet-name>
<servlet-class>Bar</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Foo</servlet-name>
<servlet-mapping>*.do</servlet-mapping>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
</web-app>
<!ELEMENT web-app (icon?, display-name?, description?, distributable?,
context-param*, servlet*, servlet-mapping*, session-config?,
mime-mapping*, welcome-file-list?, error-page*, taglib*,
resource-ref*, security-constraint*, login-config?, security-role*,
env-entry*, ejb-ref*)>
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
More information about the jdom-interest
mailing list