Servlet plugin modules enable you to deploy Java servlets as a part of your plugins.

The Servlet Plugin Module

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>

 

Accessing Your Servlet

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:

There is an example servlet module within the helloworldservlet example.

Find this example in the /plugins/helloworldservlet directory within your Confluence distribution.