my dog learned polymorphism
The moose likes Servlets and the fly likes Why servlet-name tag  is there? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Why servlet-name tag  is there?" Watch "Why servlet-name tag  is there?" New topic

Why servlet-name tag is there?

Pranav Pal
Ranch Hand

Joined: Nov 04, 2007
Posts: 74
Why cannot

be replaced by

Why is the need of <servlet-name> tag?

Hakuna Matata!
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

The first one declares your servlet.

The second one creates a mapping for your servlet.
You can have multiple mappings that point to the same servlet.
You can also declare a servlet with a jsp-file instead of a servlet class.
You can also have multiple servlet entries with the same servlet class (and different configurations).

All of this would be hard to express in a singe tag.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
wood burning stoves
subject: Why servlet-name tag is there?
It's not a secret anymore!