This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet tags declared before servlet-mapping

 
Angel J Gama
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I was reading the Invoker Servlet FAQ and it says that:
...
The Middling Tale
...
Order of elements in web.xml is very important. So when you go to create your second 'couplet', make sure all your <servlet> tags are declared before your <servlet-mapping> tags. You'll maybe want to keep the 'couplets' together, because it will be easier to see which one belongs to which, but don't do it!

I've been writing the <servlet-mapping> tag just after its own <servlet> tag and I haven't had problems.
Does any one knows why don't keep 'couplets' together?
[ August 31, 2008: Message edited by: Angel J Gama ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64973
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of servlets are you using? The order was relaxed for 2.4 which uses XML Schema rather than a DTD.
 
Angel J Gama
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using servlet spec 2.5 (tomcat 6.x)...

would it be a good "practice/convention" to code <servlet> tags first, and then <servlet-mapping> tags?
Thanks
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In practice it is easier to manage by coupling the servlet and servlet-mappings, as it is easier to manage if you end up with a large number of servlets ie it scales better.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic