• 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

question on order of elements in web.xml

 
Ranch Hand
Posts: 159
Eclipse IDE C++ Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 623
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Creator of Enthuware JWS+ V6
Posts: 3341
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 159
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic