Package javax.servlet

Examples of javax.servlet.AsyncContext.dispatch()


                @Override
                public void run() {
                    // This should be delayed until the original container
                    // thread exists
                    async.dispatch("/ServletB");
                }
            });

            try {
                Thread.sleep(3000);
View Full Code Here


                    TestAsyncContextImpl.track("Complete-");
                    ctxt.complete();
                    break;
                case DISPATCH:
                    TestAsyncContextImpl.track("Dispatch-");
                    ctxt.dispatch("/error/nonasync");
                    break;
                case NO_COMPLETE:
                    TestAsyncContextImpl.track("NoOp-");
                    break;
                default:
View Full Code Here

                            new ServletResponseWrapper(resp));
                } else {
                    asyncContext = req.startAsync();
                }
                if ("y".equals(req.getParameter(EMPTY_DISPATCH))) {
                    asyncContext.dispatch();
                } else {
                    asyncContext.dispatch("/target");
                }
                try {
                    asyncContext.dispatch("/nonExistingServlet");
View Full Code Here

                    asyncContext = req.startAsync();
                }
                if ("y".equals(req.getParameter(EMPTY_DISPATCH))) {
                    asyncContext.dispatch();
                } else {
                    asyncContext.dispatch("/target");
                }
                try {
                    asyncContext.dispatch("/nonExistingServlet");
                    TestAsyncContextImpl.track("FAIL");
                } catch (IllegalStateException e) {
View Full Code Here

                    asyncContext.dispatch();
                } else {
                    asyncContext.dispatch("/target");
                }
                try {
                    asyncContext.dispatch("/nonExistingServlet");
                    TestAsyncContextImpl.track("FAIL");
                } catch (IllegalStateException e) {
                    TestAsyncContextImpl.track("OK");
                }
            } else {
View Full Code Here

        });

        System.out.println("====filter servlet 1  before dispatch");
        //异步下分派过去的请求,异步filter也可以拦截
        //如果filter不是DispatcherType.ASYNC 类型,那么分派到/filter2时,拦截器不会调用
        asyncContext.dispatch("/filter2");
        System.out.println("====filter servlet 1  after dispatch");

        System.out.println("====filter servlet 1  after");

View Full Code Here

            }
        });

        System.out.println("====filter servlet 2  before dispatch");
        req.setAttribute("msg", "success");
        asyncContext.dispatch("/WEB-INF/jsp/dispatch.jsp");
        System.out.println("====filter servlet 2  after dispatch");

        System.out.println("====filter servlet 2  after");

View Full Code Here

            @Override
            public void onStartAsync(final AsyncEvent event) throws IOException {
                System.out.println("=====start new async");
            }
        });
        asyncContext.dispatch("/error"); //分派到一个不存在的地址 会报404,但是最终服务器会调用onComplete来完成异步
    }
}
View Full Code Here

                    Thread.sleep(3L * 1000);
                } catch (InterruptedException e) {
                }
                req.setAttribute("ok", "true");
                req.setAttribute("msg", "success");
                asyncContext.dispatch("/WEB-INF/jsp/dispatch.jsp");
            }
        }).start();

    }
}
View Full Code Here

                        Thread.sleep(3L * 1000);
                    } catch (InterruptedException e) {
                    }
                    req.setAttribute("ok", "true");
                    req.setAttribute("msg", "success");
                    asyncContext.dispatch();
                    System.out.println("===after dispatch before handle:" + req.isAsyncStarted());
                }
            }).start();

            return;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.