aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Question related to order of elements inside Servlet element in DD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Question related to order of elements inside Servlet element in DD" Watch "Question related to order of elements inside Servlet element in DD" New topic
Author

Question related to order of elements inside Servlet element in DD

Sagar Shroff
Ranch Hand

Joined: Jun 07, 2011
Posts: 208

source: http://www.javaprepare.com/scwd/quests/dd.html

# Which of these is true about deployment descriptors. Select the one correct answer.

1. The order of elements in deployment descriptor is not important. The elements can follow any order.
2. The elements of deployment descriptor are case insensitive.
3. The servlet-mapping element, if defined, must be included within the servlet element.
4. The web-app element must include the servlet element.

the correct answer is a.

I agree answer A is write according to what was mentioned in the SCWCD hints link,it says
Top level web.xml elements can appear in any order as compared to the servlet 2.3 specification. However, the order still matters within the elements inside the top-level elements - <servlet>, for example.

Now i just tested on tomcat 6 and it worked fine even if i put servlet-name element after servlet-class.Is this container specific ??

P.s Quick reply needed if possible.

Regards
Sagar.

OCJP-90%,OCPWCD-95%
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1716
    
  25

From the Servlet 3.0 specs:
14.2 Rules for Processing the Deployment Descriptor
The sub elements under web-app can be in an arbitrary order in this version of the specification.


Regards,
Frits
Sagar Shroff
Ranch Hand

Joined: Jun 07, 2011
Posts: 208

Thanks Frits

Regards,
Sagar
Sagar Shroff
Ranch Hand

Joined: Jun 07, 2011
Posts: 208

But i am giving SCWCD5 so in that i guess it is mandatory !??? Also can someone Please let me know about this statement the oder of listeners is defined in DD ? i am not able to get this statement .
How ? i mean if there is session listener and context listeners they are always gonna be executed when the EVENT occurs.Tomorrow is my exam please let me know if possible



Regards,
Sagar.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1716
    
  25

But i am giving SCWCD5 so in that i guess it is mandatory !???

This phrase "The sub elements under web-app can be in an arbitrary order in this version of the specification" is also there in the Servlet 2.4 specs.

Regards,
Frits
Charles Lyons
Author
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
The difference is whether your web.xml uses an older XML DTD doctype (where orders of elements are strict), or the newer XML Schema (ordering can be loose).

Java EE 1.4 onwards use the Schemas to define the XML content, and therefore the order is generally not important.


Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )
Sagar Shroff
Ranch Hand

Joined: Jun 07, 2011
Posts: 208

Thank You Frits and Charles !!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Question related to order of elements inside Servlet element in DD