刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 1 | <%--
|
| 2 | Licensed to the Apache Software Foundation (ASF) under one or more
|
| 3 | contributor license agreements. See the NOTICE file distributed with
|
| 4 | this work for additional information regarding copyright ownership.
|
| 5 | The ASF licenses this file to You under the Apache License, Version 2.0
|
| 6 | (the "License"); you may not use this file except in compliance with
|
| 7 | the License. You may obtain a copy of the License at
|
| 8 |
|
| 9 | http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
|
| 11 | Unless required by applicable law or agreed to in writing, software
|
| 12 | distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 | See the License for the specific language governing permissions and
|
| 15 | limitations under the License.
|
| 16 | --%>
|
| 17 | <%@page session="false"%>
|
| 18 |
|
| 19 | <pre>
|
| 20 | Use cases:
|
| 21 |
|
| 22 | 1. Simple dispatch
|
| 23 | - servlet does startAsync()
|
| 24 | - background thread calls ctx.dispatch()
|
| 25 | <a href="<%=response.encodeURL("/examples/async/async0")%>"> Async 0 </a>
|
| 26 |
|
| 27 | 2. Simple dispatch
|
| 28 | - servlet does startAsync()
|
| 29 | - background thread calls dispatch(/path/to/jsp)
|
| 30 | <a href="<%=response.encodeURL("/examples/async/async1")%>"> Async 1 </a>
|
| 31 |
|
| 32 | 3. Simple dispatch
|
| 33 | - servlet does startAsync()
|
| 34 | - background thread calls writes and calls complete()
|
| 35 | <a href="<%=response.encodeURL("/examples/async/async2")%>"> Async 2 </a>
|
| 36 |
|
| 37 | 4. Simple dispatch
|
| 38 | - servlet does a startAsync()
|
| 39 | - servlet calls dispatch(/path/to/jsp)
|
| 40 | - servlet calls complete()
|
| 41 | <a href="<%=response.encodeURL("/examples/async/async3")%>"> Async 3 </a>
|
| 42 |
|
| 43 | 3. Timeout s1
|
| 44 | - servlet does a startAsync()
|
| 45 | - servlet does a setAsyncTimeout
|
| 46 | - returns - waits for timeout to happen should return error page
|
| 47 |
|
| 48 | 4. Timeout s2
|
| 49 | - servlet does a startAsync()
|
| 50 | - servlet does a setAsyncTimeout
|
| 51 | - servlet does a addAsyncListener
|
| 52 | - returns - waits for timeout to happen and listener invoked
|
| 53 |
|
| 54 | 5. Dispatch to asyncSupported=false servlet
|
| 55 | - servlet1 does a startAsync()
|
| 56 | - servlet1 dispatches to dispatch(/servlet2)
|
| 57 | - the container calls complete() after servlet2 is complete
|
| 58 | - TODO
|
| 59 |
|
| 60 | 6. Chained dispatch
|
| 61 | - servlet1 does a startAsync
|
| 62 | - servlet1 does a dispatch to servlet2 (asyncsupported=true)
|
| 63 | - servlet2 does a dispatch to servlet3 (asyncsupported=true)
|
| 64 | - servlet3 does a dispatch to servlet4 (asyncsupported=false)
|
| 65 |
|
| 66 |
|
| 67 | 7. Stock ticker
|
| 68 | <a href="<%=response.encodeURL("/examples/async/stockticker")%>"> StockTicker </a>
|
| 69 | </pre> |