Check for a behavior change on asynchronous servlets

In the Servlet 3.0 specification, if a query string is included with a request, this string is made available to the dispatched resource. In the Servlet 3.1 specification, if a query string is provided to the dispatching resource, this query string is made available to the dispatched resource instead of the query string from the original request.

The following example demonstrates this difference in behavior:


Request for /FirstResource?param=One

First Resource:

getParameter("param"); // returns "One"

Forward request to /SecondResource?param=Two

SecondResource:

getParameter("param"); // returns "Two"
AsyncContext ac = getAsyncContext();
ac.start();
ac.dispatch(); // dispatches to /FirstResource

First Resource:

Servlet-3.0 feature : getParameter("param") returns "One"
Servlet-3.1 feature : getParameter("param") returns "Two"

Obtaining the request or response object after calling the AsyncContext.dispatch() or AsyncContext.complete() methods is not permitted and results in the following exception:

java.lang.IllegalStateException: SRVE9015E: Cannot obtain the request or response object after an AsyncContext.dispatch() or AsyncContext.complete().

This rule flags the following items:

For more information on Servlet 3.1 behavior changes, see the following resource: Servlet 3.1 behavior changes.