Reputation: 85476
What is the meaning of web.xml id attribute of the web-app tag?
Eclipse generated it as id="WebApp_ID". I was using version the Servlet specification version 2.5, I switched to using 3.0, with the suggestion of this answer that doesn't include that id.
Is it really necessary? What is the value supposed to be?
Upvotes: 14
Views: 9889
Reputation: 33936
The newer versions of the servlet spec use .xsd files with no further information on the id attribute, but if you go back to the older versions with .dtd, such as web_app_2_2.dtd, you find:
The ID mechanism is to allow tools to easily make tool-specific references to the elements of the deployment descriptor. This allows tools that produce additional deployment information (i.e information beyond the standard deployment descriptor information) to store the non-standard information in a separate file, and easily refer from these tools-specific files to the information in the standard web-app deployment descriptor.
For example, WebSphere Application Server used the id mechanism in its old bnd and ext files:
web.xml:
<web-app id="WebApp_ID" ...
ibm-web-app-bnd.xmi:
<webappbnd:WebAppBinding ...
<webapp href="WEB-INF/web.xml#WebApp_ID"/>
(Thankfully, this is tool-friendly-but-developer-annoying use of id attributes is no longer necessary with the newer .xml file format for ibm-web-bnd/ext, but I digress.)
Upvotes: 16
Reputation: 7779
AFAIK this is not needed (per the DTD as well). You can comment it out and see if that works, I am quite positive the app will load up just fine.
Upvotes: 2