I am testing simple application in jboss 7.1.1 final and servlet 3.0
feature. inside doGet/doPost I am starting AsynContext and adding the
AsyncListener().
now when I am closing the browser, I am expecting it will hit the onError
method, but it never.
Let me know if this is valid case.
--------code abstract----------------------
-
@WebServlet(urlPatterns = "/myPage", asyncSupported=true)
public class MyActionServlet extends HttpServlet {
public MyActionServlet(){
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
process(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
process(req,resp);
}
private void process(HttpServletRequest req, HttpServletResponse resp)
{
System.out.println("Hello world");
req.getSession();
AsyncContext async = req.startAsync();
async.addListener(new AsyncListener() {
@Override
public void onTimeout(AsyncEvent event) throws IOException {
System.out.println("onTimeout:event::"+event);
}
@Override
public void onStartAsync(AsyncEvent arg0) throws IOException {
System.out.println("onstart::");
}
@Override
public void onError(AsyncEvent event) throws IOException {
System.out.println("onError.."+event);
}
@Override
public void onComplete(AsyncEvent event) throws IOException {
System.out.println("onComplete::"+event);
}
});
}
}