Servlets: where did you look for web.xml files? How to merge multiple web.xml files?

I know from the Servlet 3 specification that I am web.xmllooking for in a directory WEB-INF/. However, I believe there are other files web.xml. For example, Tomcat has a web.xmlfile in$CATALINA_BASE/conf/ . I think you can also put the file web.xmlunder $CATALINA_HOME/conf/.

Is it correct that there may be several files web.xml? If so, in what places can they be located and in what order are they processed, and what is the semantics for their "merging"? (The Servlet spec says merging files web-fragment.xml, but I assume this is a separate thing.)

+4
source share
1 answer

There are two different sides to your question.

Tomcat own web.xml

The servlet specification allows the container (Tomcat here) to define some default components (JSP, default servlet ...). As you saw, Tomcat provides the default web.xml for this (and only one, in $CATALINA_BASE/conf/web.xml). This web.xml allows Tomcat to customize among other things :

  • Default servlet (which serves files directly)
  • Servlet ssp for compiling and executing jsp (and jspx) files
  • Differents. mime mapping

Tomcat web.xml is always parsed before it is applied to the application. That way, any application can override the values ​​defined by tomcat.

, : Tomcat web.xml, webapps ( $CATALINA_BASE/conf) webapp own web.xml.

-fragment.xml

3.0 , web.xml WEB-INF/web.xml META-INF/web-fragment.xml, webapp (WEB-INF/classes WEB-INF/lib).

, -.

Tomcat web.xml logEffectiveWebXml (. )

+3

Source: https://habr.com/ru/post/1543988/


All Articles