An SO User
An SO User

Reputation: 24998

What is the <webapp> tag in deployment descriptor?

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd" version="2.4">

This is the <webapp> tag that I typed from Head First: Servlets and JSP and it says that I do not have to ever memorize this and that I should simply copy-paste this. That is just not my habit.

Just curious as to what it all means.

I would be glad if someone could, in simple words, explain what the various attributes of the tag are.

Upvotes: 1

Views: 938

Answers (2)

matsev
matsev

Reputation: 33749

There is a slight typo in your schemaLocation url, it should read http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd . Following that link, you will find the definitions of the XSD (or XML Schema Definition) of which xml tags that are allowed in the web.xml document. Moreover, the xsd contains useful documentation of all the tags, specifically the <webapp> tag is described as:

The web-app element is the root of the deployment descriptor for a web application. Note that the sub-elements of this element can be in the arbitrary order. Because of that, the multiplicity of the elements of distributable, session-config, welcome-file-list, jsp-config, login-config, and locale-encoding-mapping-list was changed from "?" to "*" in this schema. However, the deployment descriptor instance file must not contain multiple elements of session-config, jsp-config, and login-config. When there are multiple elements of welcome-file-list or locale-encoding-mapping-list, the container must concatinate the element contents. The multiple occurance of the element distributable is redundant and the container treats that case exactly in the same way when there is only one distributable.

Note: if you are running on a servlet 3.0 compatible container, you can updated the xsd schema version to 3.0 and schemaLocation to http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd .

Upvotes: 2

TheWhiteRabbit
TheWhiteRabbit

Reputation: 15758

<web-app> provides configuration for your entire web-application with key information like id , servlet specification version etc

More detailed here

Upvotes: 1

Related Questions