aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes question on order of elements in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "question on order of elements in web.xml" Watch "question on order of elements in web.xml" New topic
Author

question on order of elements in web.xml

Mark Uppeteer
Ranch Hand

Joined: Mar 02, 2004
Posts: 159

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.

But if I put your servlet mapping before your servlet tag, my tomcat refuses to deploy.



so it seems the order does matter?


I know where my towel is. (SCJP 5, OCPJWCD)
[Free Quiz Tips for a fun night with friends or family] Flash games
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

Howdy Mark!

I have changed the order you are talking about and there was no problem in my case (Tomcat 7).



It just works fine, and this is what you can read in the Servlet 3 spec (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.


The question is: what version of Servlets do you use, what does the specification for this version say and what version of Servlets did the author of the question use.

Cheers!


OCP Java SE 6 Programmer, OCM Java SE 6 Developer, OCE Java EE 6 JSPSD, OCE Java EE 6 EJBD, OCE Java EE 6 JPAD, Spring 3.0 Core Professional.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1731
    
  25

Even in Servlet 2.4 (tomcat 5.5) it is like that:
The sub elements under web-app can be in an arbitrary order in this version of the specification


Regards,
Frits
Mark Uppeteer
Ranch Hand

Joined: Mar 02, 2004
Posts: 159

bizar... I use apache-tomcat-6.0.29

but I'm not going to dig this one out now, the exam is to close for that.
Its supposed to work and that will be my answer.

thanks a lot guys!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: question on order of elements in web.xml