File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes All servlets in Web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "All servlets in Web application" Watch "All servlets in Web application" New topic

All servlets in Web application

Rahul Juneja
Ranch Hand

Joined: Aug 03, 2002
Posts: 425
Hi All,
Can anybody help me how to find the names of all the servlets in a Web application. This is through the Java code only. I mean is there any method in API to find the name of all the servlets of any web application.
Rahul Juneja
[ April 26, 2004: Message edited by: Rahul Juneja ]

Rahul Juneja
ThoughtClicks -
Chris Stehno
Ranch Hand

Joined: Feb 26, 2001
Posts: 180
There used to be a way to do this from the core servlets API; however, it was deemed a security risk and the methods were deprected... and they no longer work.
The only other way I know of to do this would require access to the APIs for the server itself (at least on Tomcat). You would have to use some of the server management APIs to access the server itself rather than just a single application.
Hope this helps.

- Chris Stehno, SCPJ
Rahul Juneja
Ranch Hand

Joined: Aug 03, 2002
Posts: 425
Can you give any Example and be more precise on this. Any Server API Example and it would be great if you can come across with a Solution for WebSphere or Weblogic but any server will work.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
You could read and parse the web.xml file - this would work only if the "invoker" was not in use.
You could scan all of the class files under WEB-INF, counting the ones that implement the Servlet interface.
I agree. Here's the link:
subject: All servlets in Web application
It's not a secret anymore!