How can I get Confluence context name?

I want to get the context name of confluence. So in
http://localhost:1990/confluence
I want to get the “confluence” name in this example. As in some servers, context is defined as empty so sometime I will get “”.

If you’re doing it on the client - then AJS.contextPath() would give it to you. If you’re doing in in java - get the base url of the instance.

Don’t rely on the contextPath of the servlet (since you’re dealing with the various proxy configuration): https://docs.atlassian.com/ConfluenceServer/javadoc/7.2.0/com/atlassian/confluence/setup/settings/SettingsManager.html check the globalSettings.

1 Like

I need it in server side. I need the confluence context name exactly not the contextPath for some porpuses.

I couldn’t find any solution by Atlassian. So I did it by programming.