Make sure the spacer filter allows asynchronous. Here is what it looks like in the web.xml file:
<filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> <async-supported>true</async-supported> </filter>
Then, from within the Action, we get HttpServletRequest and HttpServletResponse and use AsyncContext in the same way as in the servlet:
public String execute() { HttpServletRequest req = ServletActionContext.getRequest(); HttpServletResponse res = ServletActionContext.getResponse(); final AsyncContext asyncContext = req.startAsync(req, res); asyncContext.start(new Runnable() { @Override public void run() { try {
source share