Package javax.servlet

Examples of javax.servlet.AsyncContext.complete()


                        try {
                            os.write("TEST".getBytes(StandardCharsets.UTF_8));
                            os.flush();
                            Thread.sleep(1000);
                        } catch (Exception e) {
                            asyncCtxt.complete();
                            break;
                        }
                    }
                }
            });
View Full Code Here


                    Thread.currentThread().setName("Async2-Thread");
                    log.info("Putting AsyncThread to sleep");
                    Thread.sleep(2*1000);
                    log.info("Writing data.");
                    actx.getResponse().getWriter().write("Output from background thread. Time:"+System.currentTimeMillis()+"\n");
                    actx.complete();
                }catch (InterruptedException x) {
                    log.error("Async2",x);
                }catch (IllegalStateException x) {
                    log.error("Async2",x);
                }catch (IOException x) {
View Full Code Here

            AsyncContext actxt = req.startAsync();
            actxt.setTimeout(3000);
            resp.setContentType("text/plain");
            resp.getWriter().print("OK");
            actxt.complete();
        }
    }

    @Test
    public void testTimeoutListenerCompleteNoDispatch() throws Exception {
View Full Code Here

                public void run() {
                    try {
                        Thread.sleep(THREAD_SLEEP_TIME);
                        asyncContext.getResponse().getWriter().write(
                                "Runnable-");
                        asyncContext.complete();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
View Full Code Here

                        Thread.sleep(THREAD_SLEEP_TIME);
                        resp.setHeader("A", "xyz");
                        resp.setContentType("text/plain");
                        resp.setContentLength("OK".getBytes().length);
                        resp.getWriter().print("OK");
                        ctx.complete();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
View Full Code Here

        protected void doGet(HttpServletRequest req, HttpServletResponse resp)
                throws ServletException, IOException {

            AsyncContext actxt = req.startAsync();
            resp.setStatus(status);
            actxt.complete();
        }
    }

    @Test
    public void testBug51197a() throws Exception {
View Full Code Here

                            HttpServletResponse resp =
                                    (HttpServletResponse) actxt.getResponse();
                            resp.sendError(status, ERROR_MESSAGE);
                            // Complete so there is no delay waiting for the
                            // timeout
                            actxt.complete();
                        } catch (IOException e) {
                            // Ignore
                        }
                    }
                });
View Full Code Here

            final AsyncContext ctxt = req.getAsyncContext();

            switch(mode) {
                case COMPLETE:
                    writer.write("Complete-");
                    ctxt.complete();
                    break;
                case DISPATCH:
                    writer.write("Dispatch-");
                    ctxt.dispatch("/error/nonasync");
                    break;
View Full Code Here

            AsyncContext actxt = req.startAsync();
            actxt.setTimeout(3000);
            resp.setContentType("text/plain");
            resp.getWriter().print("OK");
            actxt.complete();
        }
    }

    @Test
    public void testTimeoutListenerCompleteNoDispatch() throws Exception {
View Full Code Here

                public void run() {
                    try {
                        Thread.sleep(THREAD_SLEEP_TIME);
                        asyncContext.getResponse().getWriter().write(
                                "Runnable-");
                        asyncContext.complete();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
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.