Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java, tomcat: what is the meaning of the id attribute in the tag web-app in web.xml?

Tags:

java

tomcat7

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?

like image 546
stivlo Avatar asked May 11 '11 04:05

stivlo


People also ask

What is web-app ID?

Web apps often require users to authenticate to access protected content. App ID uses the OIDC authorization code flow to securely authenticate users. With this flow, when the user is authenticated, the app receives an authorization code. The code is then exchanged for an access, identity, and refresh token.

What is web xml file in Tomcat?

XML. The web. xml file is derived from the Servlet specification, and contains information used to deploy and configure the components of your web applications. When configuring Tomcat for the first time, this is where you can define servlet mappings for central components such as JSP.

How do I add web xml to an existing project?

Browse to the webapps\ch11\WEB-INF directory, and click Open. Then in the New File dialog that appears, enter the name of the file to link to, web. xml , and click OK. This adds web.


2 Answers

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.)

like image 145
Brett Kail Avatar answered Sep 18 '22 13:09

Brett Kail


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.

like image 39
lobster1234 Avatar answered Sep 19 '22 13:09

lobster1234