Add Web-Sections to Servlets Implements Web Interface Manager not displaying sections

I am interested to know how to add custom web sections to servlets in confluence. I have been able to successfully create servlets, macros, web sections and web items, however, I do not know how to get the web sections and macros to display on the servlet page.

We’ll probably need more information about what you’re trying to do.

Are you trying to render web-panel module content on your own servlet? In that case - take a look at WebInterfaceManager WebInterfaceManager | Atlassian Plugins - Parent POM .

If you’re just trying to get the shell around the page - then you’ll want to take a look at the decorators: Using Standard Page Decorators

Hi Daniel,

Sorry I could not reply earlier I was flagged as a robot for typing to fast.

I checked out what you were saying and I have determined I do not have enough information to correctly implement the WebInterfaceManager.

What I have done is tried to implement the interface on the servlet, and wrote the methods to override the interface. This method was unsuccessful but it did not break the plugin. My guess is at this point the servlet does not directly implement the interface but references it from an implementation class. If there are any documents or code that you have that does load a menu using the WebInterfaceManager it would be helpful.

You shouldn’t have to implement any methods. I’ve created a sample plugin at Bitbucket

But basically:

public class MyServlet extends HttpServlet{
    private static final Logger log = LoggerFactory.getLogger(MyServlet.class);

    private final WebInterfaceManager webInterfaceManager;

    private MyServlet( final WebInterfaceManager webInterfaceManager)
        this.webInterfaceManager = webInterfaceManager;

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException

        Map<String, Object> context = new HashMap<>();

        for(WebPanel webPanel: this.webInterfaceManager.getWebPanels("my-location"))

            resp.getWriter().write( webPanel.getHtml(context));



Note the @ComponentImport on the WebInterfaceManager which is then injected to the constructor. Once you have that - you can just call the getWebPanels method on it. The String passed in is the location that you’d want to use.

1 Like