HttpServletFilter does not send a custom response

Hello :slight_smile:

I’m currently writing an extension (with a confluence http filter module) for redirecting mobile users to another mobile site - for example, mobile users should simply get a response like <html>...<script src='...'></script></html>, nothing else. My current problem is, that my custom response is mixed somehow with the normal website… the script tag is inside the body tag of the normal page.

After detecting the mobile device in the doFilter-Method I do the following:

httpServletResponse.getWriter().write("" +
                            "<html>" +
                            "<head>" +
                            "</head>" +
                            "<body>" +
                            "<app></app>" +
                            "<script src='" +
                            "" +

The script-tag is included within the normal website, how can I load only my few custom lines when someone is using a mobile phone?

Thanks - btw, the build-in Confluence Mobile Theme is disabled.

Also - the chain.doFilter(request,response);-Method is never called on mobile devices.

You can/should do it through a servlet-filter. Can you post the lines of your servlet-filter definition from the atlassian-plugin.xml ?My guess is that your weight/location isn’t far enough up in the chain so the mobile ui intercepts it.

Hi daniel,

thank you for your response! The error was that the location-attribute in the <servlet-filter> was not before-decoration.

I still have another problem… I’m trying to get a absolute link to some web resources (like this one, so I can refer to (for example) a javascript with the generated url.

String iconURL =
        StaticAccessor.getWebResourceUrlProvider() ...

I can’t access StaticAccessor, do I need a dependency for that?

Also, I can’t include com.atlassian.confluence in my pom.xml:


The version does not work, but do I need such a dependency?

Thanks! :slight_smile:

I think the StaticAccessor.getWebResourceUrlProvider() not available for confluence.
Maybe only for jira, I not really sure.
You can just autowired WebResourceUrlProvider.

Thank you for your response Sahal :slight_smile:
After adding the spring dependency to my pom.xml-file I can access the @Autowired-Attribute:


But it seems like the HttpServletFilter does is not in the Spring Scope, because

private WebResourceUrlProvider webResourceUrlProvider;

is always null. Is there an easy way to access the WebResourceUrlProvider with Spring in a Filter?


I use this for spring


Maybe you can try Non-autowired way. Refer this docs.

Its good if you read this too .