I am currently trying to use System Properties to determine which property file to load for a Generic Servlet as described below. I would like to access the System Property "platform.type" in particular, though if this is possible, I will also use others such as "serverName".
I have already been through multiple posts regarding the following: ContextLoaderListener and ContextLoaderServlet. They will not work for this case because I need those properties accessible when the Generic Servlet accesses the above listed Context Parameter.
I have even created a Wrapper Servlet, let's call it GenericInitializationServlet, in which I attempt to replace the properties by: using a ServletConfig Proxy to access the Context Properties using the getContextParameter method and then substituting the property value with the matching System Property.
Does anyone know of a way to accomplish this? To reiterate, I need to perform property replacement on a Context Parameter that will be used by a Servlet.
Whether you think you can or whether you think you can't, you're right. ~ Henry Ford.
I'm pretty sure you can't manipulate the init parameters in a container-independent way. There is simply no standard API for this.
One of the things I can think of is using your own ServletContext implementation, that would wrap the original one and implement the getInitParameter method appropriately. Is that what you meant by "proxy"? Have you tried it?
posted 10 years ago
Below you can find the code I was able to get to work: