-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
47817144
I have a simple Async servlet. doGet method simply starts an async and dispatch the request to a JSP in runable task. I create a simple response wrapper to see if getWriter or getOutputStream of the wrapper will be called or not when dispatch JSP called. See the code:
@WebServlet(asyncSupported = true, urlPatterns =
{ "/testAsync.do" })
public class TestAsyncServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
final AsyncContext ac = req.startAsync(req, new TestAsyncRespWrapper(resp));
ac.start(new Runnable() {
@Override
public void run() {
try
catch (InterruptedException ex) {
}
ac.dispatch("/WEB-INF/jsp/testAsync.jsp");
}
});
}
static class TestAsyncRespWrapper extends HttpServletResponseWrapper {
public TestAsyncRespWrapper(HttpServletResponse resp)
{ super(resp); } @Override
public PrintWriter getWriter() throws IOException
@Override
public ServletOutputStream getOutputStream() throws IOException
}
}
testAsync.jsp:
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
<title>Test Async</title>
</head>
<body>
<h2>This is a JSP</h2>
<% System.out.println("Response class in JSP: " + response.getClass()); %>
</body>
</html>
----- ISSUE -----
Deploy the Servlet and run http://localhost:8080/app-test/testAsync.do
See JSP content generated displays in the browser - OK
BUT: the response wrapper getWriter() OR getOutputStream never get called.
System.out in JSP prints: Response class in JSP: class io.undertow.servlet.spec.HttpServletResponseImpl
----- NOTE ----
If I create a Servlet Filter and move the response wrapper into the filter --> I get the same issue.
----- EXPECTED -----
the response wrapper getWriter() OR getOutputStream will be called.
And
System.out in JSP prints: Response class in JSP: class TestAsyncRespWrapper