In the previous recipe, we saw how to deploy a servlet and how to make use of the init params. What if we have a set of servlets or servlet filters or context listeners that make use of the same parameters? Do we really need to initialize them in all the plugin modules?
In this recipe, we will see how we can use the Servlet Context Parameter plugin module to share parameters across servlets, filters, and listeners.
All we need to do is to define the shared parameters to add a servlet-context-param
module for each shared parameter in the atlassian-plugin.xml
.
For example, a parameter with key sharedText
can be defined as follows:
<servlet-context-param key="jtricksContext"> <description>Shares this param!</description> <param-name>sharedText</param-name> <param-value>This is a shared Text</param-value> </servlet-context...