Can Confluence contain a "standalone" servlet?

Brian Alston July 29, 2015

I have been tasked with creating a "filter" for our custom Confluence plug-in that will intercept all REST requests and forward them appropriately depending on whether or not they are valid requests. For example, if somebody makes a PUT request against a GET resource, I want to redirect them to a standard error page. We have implemented this in all of our independent REST classes, but would prefer to consolidate all this to a single class.

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Midori
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2015

What you are looking for is a servlet filter, not a servlet!

Both of those are available as plugin module types: https://developer.atlassian.com/confdev/confluence-plugin-guide/confluence-plugin-module-types

Brian Alston July 30, 2015

Ok, that sounds very promising. Thank you. I was also thinking about having a single REST class that has all the annotated paths I need, then just calling the other classes for the JSON that I will return to a request, and provide errors upon bad requests. Is that also a viable option? Thanks for replying.

Brian Alston July 30, 2015

Also ... is this an actual module I need to download, or it simply annotating the atlassian-plugin.xml file?

Brian Alston July 30, 2015

Also, also ... Is the servlet filter class just a typical Servlet class?

1 vote
sushsada July 29, 2015

Yeah, it would involve you writing a java servlet class.

This tutorial has a good example for a servlet and implements the GET method. you could implement others like POST too.

https://developer.atlassian.com/docs/common-coding-tasks/creating-an-admin-configuration-form

Brian Alston July 29, 2015

I will give it a shot ... thanks.

TAGS
AUG Leaders

Atlassian Community Events