How to avoid request set ASYNC_SUPPORTED=true to enable async servlet 3.0 processing on Tomcat 7?

Jérôme Verstrynge picture Jérôme Verstrynge · Oct 21, 2011 · Viewed 8k times · Source

Following an issue reported on this question, a solution was found:

req.setAttribute("org.apache.catalina.ASYNC_SUPPORTED", true);

This seems a bit strange and is not really 'portable' code (it won't hurt, but...). It seems specific to Tomcat 7. I am using Tomcat 7.0.14 as delivered by NetBeans 7.0.1.

I could not find documentation indicating it is necessary to enable async request processing in servlet 3.0 with a catalina attribute. I could not find documentation indicating something special was necessary at the Tomcat configuration level too.

Is there a way to avoid having to set ASYNC_SUPPORTED=true in each request to enable async servlet 3.0 processing in Tomcat 7?

Answer

kschneid picture kschneid · Dec 24, 2012

A couple of things to check first:

Make sure any filters that operate on the request also support async (as addressed in one of the answers to the question you referenced).

Make sure you're using a Servlet 3.0 web.xml - for example:

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                             http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0"
         metadata-complete="true">