Calling plug-in actions from anywhere?


Does it exists a global function similar to the provided by the following method;

com.atlassian.jira.web.action.JiraWebActionSupport.getRedirect(String arg0)

It returns the url for any other action defined in the plugin, but it can only be invoked by an action extending the JiraWebActionSupport class.

I need to call an action from a menu.

Many thanks,


1 answer

1 accepted

1 vote
Accepted answer

You should be able to call it from anywhere using a link like this:


Doesn't that work? For a menu, use a web-item.


Just what I was looking for!

But it has a little problem: the context of the JIRA application:

  1. In production usually: http://localhost/ (empty)
  2. In SDK or other times: http://localhost/jira</li<>>

In the first case, it must be invoked: /secure/YourActionName.jspa

Inthe second: /jira/secure/YourActionName.jspa

Is there an API function providing the context? Maybe by analyzing the JIRA base url to get it...

I believe ActionContext.getResponse().sendRedirect(location) will append the correct contextPath. Haven't tried it though, but the Javadocs seem accurate enough

This method can accept relative URLs; the servlet container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root.

You can also build the url client-side. There should be a

&lt;script type="text/javascript"&gt;var contextPath = '';&lt;/script&gt;

on every page, with the appropriate value.

Florin is right, but there is an even easier way, your Action classes (should?) probably subclass JiraWebActionSupport, and so, can call: getRedirect("secure/yourapp/Thing!view.jspa"); so long as your action then returns NULL, you will get redirected, with context set accordingly if present.

The problem is that the code is not inside an action, it's in a menu builder. Hence, neither

<script type="text/javascript">var contextPath = '';</script>

can be invoked because is a client based solution nor


because I don't want redirect anything. Simply, pass the menu links to JIRA and let it decide when to redirect (due an user action).

I got at my email another suggestion from from Andy Brook (and not listed in answers !?):

JiraWebActionSupport, and so, can call: getRedirect("secure/yourapp/Thing!view.jspa");

but as the code is not within an action... I tried to create an object by:

JireWebActionSupport jwas = new JiraWebActionSupport();

but it did not work.

Based on a Florin's suggestion I tried to get the context from the servlet:


that would be perfect. Unfortunately, as it's not invoked from within an action, ActionContext.getRequest() returns null :(

Anyway it opens a new way: is it possible to get the HttpServletRequest from ANYWHERE (not only from an action)?

If it is from a web-item, you don't need to append context path. If not, where is your code? What kind of plugin module is it?

Jobin is right. Web-items do not require a context path. So if those aren't web-items, what are they? What is that menu builder you are using? When is it called and what does it do?

The action is called from a SimpleLinkFactory (implemented by a class) as described in the following link and in the Jobin's book:

The links are built from within that class. If the contextPath is not added (/jira/secure/MyAction.jspa) then the action is not found. When the context path is present, then it works.

This will get you the full base url.


Use ComponentManager is the older JIRA versions.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

446 views 8 26
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you