Is there a way in the servlet API to access the properties specified in web.xml (for example, initialization parameters) from a Bean or Factory class that is not associated with the web container at all?
For example, I am writing a Factory class, and I would like to include some logic in Factory to check the hierarchy of files and configuration locations, to find out which ones are available, to determine which implementation the class to instantiate - for example,
- class properties file
- web.xml parameter,
- system property or
- some default logic if nothing is available.
I would like to be able to do this without inserting links to ServletConfig or anything similar to my Factory - the code should work fine outside the servlet container.
This may sound a little unusual, but I would like this component that I'm working on to be packaged with one of our web applications, and also universal enough to be packaged with some of our on-line, without requiring The new properties file is only for my component, so I was hoping to link on top of other configuration files such as web.xml.
If I remember correctly, .NET has something like Request.GetCurrentRequest() to get a link to the current executable Request - but since this is a Java application, I'm looking for something simliar that can be used to access ServletConfig .
source share