Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

All servlets in Web application

 
Rahul Juneja
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Chris Stehno
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rahul Juneja
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic