-
Feature Request
-
Resolution: Done
-
Major
-
8.2.0.Final
When a JSP is dispatched in a Async-Servlet, the AsyncListener#onComplete is never triggered.
AsyncServlet.java
@WebServlet(urlPatterns = { "/AsyncServlet" }, asyncSupported = true) public class AsyncServlet extends HttpServlet { public AsyncServlet() { super(); } @Override protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); final AsyncContext ac; if (req.isAsyncStarted()) { ac = req.getAsyncContext(); } else { ac = req.startAsync(); } ac.setTimeout(5000); ac.addListener(new AsyncListener() { @Override public void onTimeout(AsyncEvent event) throws IOException { System.out.println("onTimeout"); } @Override public void onStartAsync(AsyncEvent event) throws IOException { System.out.println("onStartAsync"); } @Override public void onError(AsyncEvent event) throws IOException { System.out.println("onError"); } @Override public void onComplete(AsyncEvent event) throws IOException { System.out.println("onComplete"); } }); System.out.println("Calling JSP..."); ac.dispatch("/result.jsp"); System.out.println("After JSP call"); } }
result.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>AsyncServletTest</title> </head> <body> <p>JSP Content</p> <% System.out.println("Start JSP"); Thread.sleep(1000); // sleep 1 seconds String resp = (String)request.getAttribute("result"); resp = resp + "<p>on JSP</p>"; Thread.sleep(1000); // sleep 1 seconds System.out.println("End JSP"); %> <p><%=resp%></p> </body> </html>