This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "All servlets in Web application" Watch "All servlets in Web application" New topic
Author

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.
Thanks,
Rahul Juneja
[ April 26, 2004: Message edited by: Rahul Juneja ]

Rahul Juneja
ThoughtClicks - http://techlabs.thoughtclicks.com
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
Chris,
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.
Cheers,
Rahul
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12756
    
    5
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.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: All servlets in Web application
 
Similar Threads
How to publish a servlet
Introductory Tutorial on Web services
starting service from java process
Form Data Lost
Where to go now?