Ik wil in m'n graag toegang hebben tot een aantal variabelen (JDBCConnectionPool etc.) vanuit verschillende Servlets. Dat moet volgens mij mogelijk zijn, ik heb gekeken naar de ServletContext class, die zegt in javadoc dit:
Dit suggereert dat indien een application niet "distributed" is dit wel kan. Mijn vraag is dan, hoe? Het enige wat in aanmerking kwam zijn de getAttribute en setAttribute methoden, maar bij getAttribute staat:In the case of a web application marked "distributed" in its deployment descriptor, there will be one context instance for each virtual machine. In this situation, the context cannot be used as a location to share global information (because the information won't be truly global). Use an external resource like a database instead.
En is dus bedoeld om niet standaard informatie van de web/jsp server te verkrijgen. Hoe moet het wel?Returns the servlet container attribute with the given name, or null if there is no attribute by that name. An attribute allows a servlet container to give the servlet additional information not already provided by this interface.