Servlet plugin modules enable you to deploy Java servlets as a part of your plugins.
Each servlet is deployed as a plugin module of type "servlet". Here is an example atlassian-plugin.xml file containing a single servlet:
<atlassian-plugin name="Hello World Servlet" key="confluence.extra.helloworld">
<plugin-info>
<description>A basic Servlet module test - says "Hello World!"</description>
<vendor name="Atlassian Software Systems" url="http://www.atlassian.com"/>
<version>1.0</version>
</plugin-info>
<servlet name="Hello World Servlet" key="helloWorld" class="com.atlassian.confluence.extra.helloworld.HelloWorldServlet">
<description>Says Hello World, Australia or your name.</description>
<url-pattern>/helloworld</url-pattern>
<init-param>
<param-name>defaultName</param-name>
<param-value>Australia</param-value>
</init-param>
</servlet>
</atlassian-plugin>
|
servlet is an subclass of javax.servlet.http.HttpServlet.web.xml.You servlet will be accessed within the Confluence web application via each url-pattern you specify, beneath the /plugins/servlet parent path.
For example, if you specify a url-pattern of /helloworld as above, and your Confluence application was deployed at http://yourserver/confluence - then you servlet would be accessed at http://yourserver/confluence/plugins/servlet/helloworld .
Some information to be aware of when developing or configuring a servlet plugin module:
init() method will not be called on web application startup, as for a normal servlet. Instead, this method will be called the first time your servlet is accessed after each time it is enabled. This means that if you disable a plugin containing a servlet, or a single servlet module, and re-enable it again init() will be called again./plugins/servlet root, be careful choosing each url-pattern under which your servlet is deployed. It is recommended to use a value that will always be unique to the world!There is an example servlet module within the helloworldservlet example.
Find this example in the /plugins/helloworldservlet directory within your Confluence distribution.