• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

name conflict in web.xml and web-fragment.xml

 
Himai Minh
Ranch Hand
Posts: 1360
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to EPractice Lab:

Configuration conflicts between the main web.xml and a web fragment are resolved such that the configuration in the web.xml takes precedence.

But when I try this:

//in web.xml
<context-param>
<param-name>B</param-name>
<param-value>30</param-value>
</context-param>




// in web-fragment.xml in A.jar's META-INF
<web-fragment 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-fragment_3_1.xsd"
version="3.1"
metadata-complete="true">

<context-param>
<param-name>valueB</param-name>
<param-value>20</param-value>
</context-param>
</web-fragment>


In my main index.jsp :
<%=application.getInitParameter("valueB")%>


Which valueB was printed? I got 20 , which comes from the web-fragment.xml.
 
Himai Minh
Ranch Hand
Posts: 1360
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I made a mistake in the web.xml. The param value should be "valueB".
Now, it prints 30, which comes from web.xml.
Please ignore this post.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic