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

Programmatic access to servlet configuration

 
Adam Michalik
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to access servlet configuration data of a given servlet (not the one currently handling the request)? I have an application with a JSF (Faces) servlet and servlet MyServlet. I want to programmatically access (read) access MyServlet's url-pattern as it was configured in web.xml from a request that is handled by the Faces Servlet. Is it possible at all?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18272
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't expect much. That sounds like something that Malware would like to be able to exploit, and if you want exploitable, Java tries very hard to be the last stop on the bus route.

Web.xml is kind of a funny critter, anyway. The application container digests it to create internal data structures for its own use - including the URL routing rules. They're not part of the webapp at all. So you're really talking about accessing server internal constructs which means that the requester would almost certainly have to know a lot about the internal organization of the server being used.
 
Adam Michalik
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Tim. I supposed that it might be a security risk to allow for such listing. I'll have to duplicate this servlet configuration in web.xml and in the place where I need it, then.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic