Package javax.servlet
Interface AsyncContext
- 
 public interface AsyncContextProvides the context for asynchronous request handling- Since:
- Servlet 3.0
 
- 
- 
Field SummaryFields Modifier and Type Field Description static java.lang.StringASYNC_CONTEXT_PATHThe attribute name for the Context Path of the async requeststatic java.lang.StringASYNC_MAPPINGThe attribute name for the Mapping of the async requeststatic java.lang.StringASYNC_PATH_INFOThe attribute name for the Path Info of the async requeststatic java.lang.StringASYNC_QUERY_STRINGThe attribute name for the Query String of the async requeststatic java.lang.StringASYNC_REQUEST_URIThe attribute name for the URI of the async requeststatic java.lang.StringASYNC_SERVLET_PATHThe attribute name for the Servlet Path of the async request
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddListener(AsyncListener listener)Adds an event listener that will be called for different AsyncEvents firevoidaddListener(AsyncListener listener, ServletRequest request, ServletResponse response)Adds an event listener that will be called when different AsyncEvents firevoidcomplete()Completes the async request processing and closes the response stream<T extends AsyncListener>
 TcreateListener(java.lang.Class<T> clazz)Creates and returns an AsyncListener objectvoiddispatch()voiddispatch(java.lang.String path)voiddispatch(ServletContext context, java.lang.String path)ServletRequestgetRequest()ServletResponsegetResponse()longgetTimeout()Get the current timeout.booleanhasOriginalRequestAndResponse()voidsetTimeout(long timeout)Set the timeout.voidstart(java.lang.Runnable run)Starts a new thread to process the asynchronous request
 
- 
- 
- 
Field Detail- 
ASYNC_REQUEST_URIstatic final java.lang.String ASYNC_REQUEST_URI The attribute name for the URI of the async request- See Also:
- Constant Field Values
 
 - 
ASYNC_CONTEXT_PATHstatic final java.lang.String ASYNC_CONTEXT_PATH The attribute name for the Context Path of the async request- See Also:
- Constant Field Values
 
 - 
ASYNC_MAPPINGstatic final java.lang.String ASYNC_MAPPING The attribute name for the Mapping of the async request- See Also:
- Constant Field Values
 
 - 
ASYNC_PATH_INFOstatic final java.lang.String ASYNC_PATH_INFO The attribute name for the Path Info of the async request- See Also:
- Constant Field Values
 
 - 
ASYNC_SERVLET_PATHstatic final java.lang.String ASYNC_SERVLET_PATH The attribute name for the Servlet Path of the async request- See Also:
- Constant Field Values
 
 - 
ASYNC_QUERY_STRINGstatic final java.lang.String ASYNC_QUERY_STRING The attribute name for the Query String of the async request- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getRequestServletRequest getRequest() - Returns:
- a reference to the ServletRequest object
 
 - 
getResponseServletResponse getResponse() - Returns:
- a reference to the ServletResponse object
 
 - 
hasOriginalRequestAndResponseboolean hasOriginalRequestAndResponse() - Returns:
- true if the Request and Response are the original ones
 
 - 
dispatchvoid dispatch() - Throws:
- java.lang.IllegalStateException- if this method is called when the request is not in asynchronous mode. The request is in asynchronous mode after- ServletRequest.startAsync()or- ServletRequest.startAsync(ServletRequest, ServletResponse)has been called and before- complete()or any other dispatch() method has been called.
 
 - 
dispatchvoid dispatch(java.lang.String path) - Parameters:
- path- The path to which the request/response should be dispatched relative to the- ServletContextfrom which this async request was started.
- Throws:
- java.lang.IllegalStateException- if this method is called when the request is not in asynchronous mode. The request is in asynchronous mode after- ServletRequest.startAsync()or- ServletRequest.startAsync(ServletRequest, ServletResponse)has been called and before- complete()or any other dispatch() method has been called.
 
 - 
dispatchvoid dispatch(ServletContext context, java.lang.String path) - Parameters:
- path- The path to which the request/response should be dispatched relative to the specified- ServletContext.
- context- The- ServletContextto which the request/response should be dispatched.
- Throws:
- java.lang.IllegalStateException- if this method is called when the request is not in asynchronous mode. The request is in asynchronous mode after- ServletRequest.startAsync()or- ServletRequest.startAsync(ServletRequest, ServletResponse)has been called and before- complete()or any other dispatch() method has been called.
 
 - 
completevoid complete() Completes the async request processing and closes the response stream
 - 
startvoid start(java.lang.Runnable run) Starts a new thread to process the asynchronous request- Parameters:
- run- a Runnable that the new thread will run
 
 - 
addListenervoid addListener(AsyncListener listener) Adds an event listener that will be called for different AsyncEvents fire- Parameters:
- listener- an AsyncListener that will be called with AsyncEvent objects
 
 - 
addListenervoid addListener(AsyncListener listener, ServletRequest request, ServletResponse response) Adds an event listener that will be called when different AsyncEvents fire- Parameters:
- listener- an AsyncListener that will be called with AsyncEvent objects
- request- the ServletRequest that will be passed with the AsyncEvent
- response- the ServletResponse that will be passed with the AsyncEvent
 
 - 
createListener<T extends AsyncListener> T createListener(java.lang.Class<T> clazz) throws ServletException Creates and returns an AsyncListener object- Type Parameters:
- T- The type to create that extends AsyncListener
- Parameters:
- clazz- The class to instantiate to create the listener
- Returns:
- the newly created AsyncListener object
- Throws:
- ServletException- if the listener cannot be created
 
 - 
setTimeoutvoid setTimeout(long timeout) Set the timeout.- Parameters:
- timeout- The timeout in milliseconds. 0 or less indicates no timeout.
 
 - 
getTimeoutlong getTimeout() Get the current timeout.- Returns:
- The timeout in milliseconds. 0 or less indicates no timeout.
 
 
- 
 
-