Java Servlet 4.0 web.xml schema definition

Note that I can't remember the schema definition of Java Servlet 4.0. I didn't know where the official definition was.

web.xml


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"                  
         version="4.0">
</web-app>

By the way, I didn't understand the meaning of the schema definition, so I looked it up.

xmlns="http://xmlns.jcp.org/xml/ns/javaee"

Define a "namespace name". This defines which namespace the tag elements and used in web.xml belong to.

xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"

(Skip one declaration) Here, the reference destination of the schema definition file (.xsd) of the namespace http://xmlns.jcp.org/xml/ns/javaee defined earlier is specified. In other words, elements such as and belong to the namespace http://xmlns.jcp.org/xml/ns/javaee, and their definition is http: // xmlns. Please refer to the definition file of jcp.org/xml/ns/javaee/web-app_4_0.xsd. " By the way, web-app_4_0.xsd seems to point to Java Servlet 4.0.

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

So, this declaration that I skipped defines the namespace to which the element schemaLocation that specifies the location of the schema definition file belongs as xsi: schemaLocation, and declares it with the alias xsi. There is.

In other words, to summarize

Two namespaces are defined in web.xml, and the usage of each is as follows.

  1. The namespace of the element (tag) used belongs to http://xmlns.jcp.org/xml/ns/javaee.
  2. http://www.w3.org/2001/XMLSchema-instance is defined only to use schemaLocation which indicates the location of the definition file of the namespace of 1.

reference

How to declare DTD / XSD by version of web.xml Namespace in XML

Recommended Posts

Java Servlet 4.0 web.xml schema definition
[Java] Servlet filter
Java constant definition
Java Servlet LifeCycle Example
[Java] Beginner's understanding of Servlet-②
[Java] Beginner's understanding of Servlet-①
Java class definition and instantiation
Java Servlet / JSP View drawing
Java Servlet / JSP Request Scope Part 1
I'm not sure about Java Servlet