aspose file tools*
The moose likes Servlets and the fly likes Servlet Name 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 » Java » Servlets
Bookmark "Servlet Name" Watch "Servlet Name" New topic
Author

Servlet Name

Ravi Bansal
Ranch Hand

Joined: Aug 18, 2008
Posts: 86
Hi guys,
I am just a beginner on servlet, i need to clear one my doubt...

Why do we have servlet name in DD. Why cant we map the class name directly with the URL pattern , the idea is to protect the name of the class file from the client.....then what is need for adding the extra layer of mapping (SERVLET NAME) between the url pattern and servlet class


SCJP 5.0 94%
OCE-EJBD 90%
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Because a servlet can be either a class name, or a JSP file.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ravi Bansal
Ranch Hand

Joined: Aug 18, 2008
Posts: 86
I did not get this answer, could you please take some time to elaborate little more? if servlet can be either a class name or JSP that why cant they be mapped to URL-Patterns directly?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

A servlet can either be a Java class or a JSP file.


or




In addition (and maybe more importantly)
You can have several servlets in service with different names and settings; all from the same class file.



You may want to give each of these two servlets their own mapping.
It would be hard to accomplish this if the name weren't abstracted from the Java class.
[ December 03, 2008: Message edited by: Ben Souther ]
Ravi Bansal
Ranch Hand

Joined: Aug 18, 2008
Posts: 86
Thanks..I got your above explanation
T. N.V.Pandian
Greenhorn

Joined: Nov 09, 2008
Posts: 2
Ravi,
There is one more reason why we use DD.If you use class names in url then the user know about the exact path of class in server,which is normally considered as a security threat.So we map the particular url pattern to a class.Hence,the user(in client side) doesn't know about servlet path which doesnt need to him.


T.N.V.Pandian,
TamilNadu,
India.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Name