This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes servlet tags declared before servlet-mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "servlet tags declared before servlet-mapping" Watch "servlet tags declared before servlet-mapping" New topic
Author

servlet tags declared before servlet-mapping

Angel J Gama
Ranch Hand

Joined: Jun 28, 2007
Posts: 36
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

Joined: Jan 10, 2002
Posts: 56214
    
  13

What version of servlets are you using? The order was relaxed for 2.4 which uses XML Schema rather than a DTD.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Angel J Gama
Ranch Hand

Joined: Jun 28, 2007
Posts: 36
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

Joined: Mar 06, 2001
Posts: 13459

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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: servlet tags declared before servlet-mapping
 
Similar Threads
Order of elements in DD and servlet/servlet-mapping
access a servlet usin its name
Cant read config params in JSP
RequestDispatcher problem
url-pattern example