• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFSJ final mock exam doubt

 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will be writing the exam Monday morning and today I decided to try HFSJ final mock. I have some doubts. Here's one of them:

Question 48 (which deals with listeners' declaration in the DD) gives this fragment as a valid answer:

<listener>
<listener-class>com.example.ListenerC</listener-class>
<description>A session listener</description>
</listener>

It seems OK at first glance, but there's something that annoys me: the order in which <listener-class> and <description> elements are presented. Accordingly to section SRV.13.3 (the DD's xsd schema):



So, all elements inside <filter> are declared in the xsd as being part of a <xsd:sequence>. If I understand it correctly, the order matters and therefore the snipped in the mock exam is wrong. The correct way should be:

<listener>
<description>A session listener</description>
<listener-class>com.example.ListenerC</listener-class>
</listener>

Am I correct or did I go too far?

I also saw that all other elements inside <web-app> are defined the same way. The only exception seems to be <web-app> itself, whose sub-elements may be in any order.

Can someone confirm (or refute) this? If possible before Monday :-)

I really appreciate your help. Thank you.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It used to be that order mattered for everything on the web.xml and you were tested on it. My understanding is that order doesn't matter anymore. At the very least, there won't be anything on the exam to test you on ordering.
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Marc!

I will follow your advice. The thing that confused me was that in XML syntax the <xsd:sequence> element is used to provide an XML representation of an ordered set of element types. This means that a web.xml that uses the <filter> declaration mentioned in my first post won't pass validation against the XML schema. However, section SRV.13.2 of the spec states:


The deployment descriptor must be valid against the schema. Web containers and tools that manipulate Web applications have a wide range of options for checking the validity of a WAR. This includes checking the validity of the deployment descriptor document held within. The containers and tools that are part of J2EE technology-compliant implementation are required to validate deployment descriptor against the XML schema for structural correctness.
The validation is recommended, but not required for the web containers and tools that are not part of J2EE technology-compliant implementation.


The paragraph in bold seems to confirm what you are saying. Many thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic