Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Piotr's mock , question 20 , web fragment discovery

 
Ranch Foreman
Posts: 1897
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q20 - Web Fragments Discovery


Considering the idea of web fragments, which statements are true:

a. web fragment's filename, to be discovered by the container, must be named "web-fragment.xml"

b. web fragment's filename, to be discovered by the container, must be named "web_fragment.xml",

c. If a web fragment is packaged as a JAR file, its web fragment XML file needs to be located at the top directory of the JAR file,

d. If a web fragment is packaged as a JAR file, its web fragment XML file needs to be located directly under META-INF/ directory of the JAR file,

e. If a web fragment packaged as a JAR file needs to be discovered by the container, it must be located somewhere in the application's classpath,

f. If a web fragment packaged as a JAR file needs to be discovered by the container, it must be located directly under WEB-INF/ directory of the application,

g. If a web fragment packaged as a JAR file needs to be discovered by the container, it must be located directly under WEB-INF/lib directory of the application.


Answer and explanation:


a, d, g

Reference: page 65, 8.2.1 "Modularity of web.xml"

Explanation: The name of the web fragment descriptor is web-fragment.xml, so b is incorrect.

If this web-fragment.xml is a part of a JAR file, it must be located under JAR's META-INF/ directory, so c is incorrect.

If this web-fragment.xml is a part of a JAR file and it's supposed to alter or contribute to the final Deployment Descriptor, it must be located under application's WEB-INF/lib directory. The container can, but is not required to discover web fragments which are not located under WEB-INF/lib.



I think for the last sentence of the explanation , the jar file should be in WEB-INF/lib directory, not the web-fragment.xml of that jar file.
In c, it has already mentioned that web-fragment.xml must be in META-INF/ if this xml is part of the jar file.
 
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic