Top Description Fields Constructors Methods
javax.servlet

public Class ServletRequestWrapper

extends Object
implements ServletRequest
Class Inheritance
All Implemented Interfaces
javax.servlet.ServletRequest
Known Direct Subclasses
javax.servlet.http.HttpServletRequestWrapper
Imports
java.io.BufferedReader, .IOException, .UnsupportedEncodingException, java.util.Enumeration, .Locale, .Map

Provides a convenient implementation of the ServletRequest interface that can be subclassed by developers wishing to adapt the request to a Servlet. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped request object.
Since
Servlet 2.3
See Also
javax.servlet.ServletRequest

Field Summary

Modifier and TypeField and Description
private ServletRequest

Constructor Summary

AccessConstructor and Description
public
ServletRequestWrapper(ServletRequest
the ServletRequest to be wrapped
request
)

Creates a ServletRequest adaptor wrapping the given request object.

Method Summary

Modifier and TypeMethod and Description
public AsyncContext

Returns:

the AsyncContext that was created or reinitialized by the most recent invocation of startAsync or startAsync(ServletRequest, ServletResponse) on the wrapped request
getAsyncContext
()

Implements javax.servlet.ServletRequest.getAsyncContext.

Gets the AsyncContext that was created or reinitialized by the most recent invocation of startAsync or startAsync(ServletRequest, ServletResponse) on the wrapped request.
public Object
getAttribute(String
a String specifying the name of the attribute
name
)

Implements javax.servlet.ServletRequest.getAttribute.

The default behavior of this method is to call getAttribute(String name) on the wrapped request object.
public Enumeration<String>
getAttributeNames()

Implements javax.servlet.ServletRequest.getAttributeNames.

The default behavior of this method is to return getAttributeNames() on the wrapped request object.
public String
getCharacterEncoding()

Implements javax.servlet.ServletRequest.getCharacterEncoding.

The default behavior of this method is to return getCharacterEncoding() on the wrapped request object.
public int
getContentLength()

Implements javax.servlet.ServletRequest.getContentLength.

The default behavior of this method is to return getContentLength() on the wrapped request object.
public long
getContentLengthLong()

Implements javax.servlet.ServletRequest.getContentLengthLong.

The default behavior of this method is to return getContentLengthLong() on the wrapped request object.
public String
getContentType()

Implements javax.servlet.ServletRequest.getContentType.

The default behavior of this method is to return getContentType() on the wrapped request object.
public DispatcherType

Returns:

the dispatcher type of the wrapped request
getDispatcherType
()

Implements javax.servlet.ServletRequest.getDispatcherType.

Gets the dispatcher type of the wrapped request.
public ServletInputStream
getInputStream()

Implements javax.servlet.ServletRequest.getInputStream.

The default behavior of this method is to return getInputStream() on the wrapped request object.
public String
getLocalAddr()

Implements javax.servlet.ServletRequest.getLocalAddr.

The default behavior of this method is to return getLocalAddr() on the wrapped request object.
public Locale
getLocale()

Implements javax.servlet.ServletRequest.getLocale.

The default behavior of this method is to return getLocale() on the wrapped request object.
public Enumeration<Locale>
getLocales()

Implements javax.servlet.ServletRequest.getLocales.

The default behavior of this method is to return getLocales() on the wrapped request object.
public String
getLocalName()

Implements javax.servlet.ServletRequest.getLocalName.

The default behavior of this method is to return getLocalName() on the wrapped request object.
public int
getLocalPort()

Implements javax.servlet.ServletRequest.getLocalPort.

The default behavior of this method is to return getLocalPort() on the wrapped request object.
public String
getParameter(String
a String specifying the name of the parameter
name
)

Implements javax.servlet.ServletRequest.getParameter.

The default behavior of this method is to return getParameter(String name) on the wrapped request object.
public Map<String, String[]>
getParameterMap()

Implements javax.servlet.ServletRequest.getParameterMap.

The default behavior of this method is to return getParameterMap() on the wrapped request object.
public Enumeration<String>
getParameterNames()

Implements javax.servlet.ServletRequest.getParameterNames.

The default behavior of this method is to return getParameterNames() on the wrapped request object.
public String[]
getParameterValues(String
a String containing the name of the parameter whose value is requested
name
)

Implements javax.servlet.ServletRequest.getParameterValues.

The default behavior of this method is to return getParameterValues(String name) on the wrapped request object.
public String
getProtocol()

Implements javax.servlet.ServletRequest.getProtocol.

The default behavior of this method is to return getProtocol() on the wrapped request object.
public BufferedReader
getReader()

Implements javax.servlet.ServletRequest.getReader.

The default behavior of this method is to return getReader() on the wrapped request object.
public String
getRealPath(String
the path for which the real path is to be returned.
path
)

Implements javax.servlet.ServletRequest.getRealPath.

Deprecated As of Version 2.1 of the Java Servlet API, use ServletContext#getRealPath instead
The default behavior of this method is to return getRealPath(String path) on the wrapped request object.
public String
getRemoteAddr()

Implements javax.servlet.ServletRequest.getRemoteAddr.

The default behavior of this method is to return getRemoteAddr() on the wrapped request object.
public String
getRemoteHost()

Implements javax.servlet.ServletRequest.getRemoteHost.

The default behavior of this method is to return getRemoteHost() on the wrapped request object.
public int
getRemotePort()

Implements javax.servlet.ServletRequest.getRemotePort.

The default behavior of this method is to return getRemotePort() on the wrapped request object.
public ServletRequest

Returns:

the wrapped ServletRequest
getRequest
()

Return the wrapped request object.

public RequestDispatcher
getRequestDispatcher(String
a String specifying the pathname to the resource. If it is relative, it must be relative against the current servlet.
path
)

Implements javax.servlet.ServletRequest.getRequestDispatcher.

The default behavior of this method is to return getRequestDispatcher(String path) on the wrapped request object.
public String
getScheme()

Implements javax.servlet.ServletRequest.getScheme.

The default behavior of this method is to return getScheme() on the wrapped request object.
public String
getServerName()

Implements javax.servlet.ServletRequest.getServerName.

The default behavior of this method is to return getServerName() on the wrapped request object.
public int
getServerPort()

Implements javax.servlet.ServletRequest.getServerPort.

The default behavior of this method is to return getServerPort() on the wrapped request object.
public ServletContext

Returns:

the servlet context to which the wrapped servlet request was last dispatched
getServletContext
()

Implements javax.servlet.ServletRequest.getServletContext.

Gets the servlet context to which the wrapped servlet request was last dispatched.
public boolean

Returns:

true if this request has been put into asynchronous mode, false otherwise
isAsyncStarted
()

Implements javax.servlet.ServletRequest.isAsyncStarted.

Checks if the wrapped request has been put into asynchronous mode.
public boolean

Returns:

true if this request supports asynchronous operation, false otherwise
isAsyncSupported
()

Implements javax.servlet.ServletRequest.isAsyncSupported.

Checks if the wrapped request supports asynchronous operation.
public boolean
isSecure()

Implements javax.servlet.ServletRequest.isSecure.

The default behavior of this method is to return isSecure() on the wrapped request object.
public boolean

Returns:

true if this ServletRequestWrapper wraps the given ServletRequest instance, false otherwise
isWrapperFor
(ServletRequest
the ServletRequest instance to search for
wrapped
)

Checks (recursively) if this ServletRequestWrapper wraps the given ServletRequest instance.

public boolean

Returns:

true if this ServletRequestWrapper wraps a ServletRequest of the given class type, false otherwise
isWrapperFor
(Class<?>
the ServletRequest class type to search for
wrappedType
)

Checks (recursively) if this ServletRequestWrapper wraps a ServletRequest of the given class type.

public void
removeAttribute(String
a String specifying the name of the attribute to remove
name
)

Implements javax.servlet.ServletRequest.removeAttribute.

The default behavior of this method is to call removeAttribute(String name) on the wrapped request object.
public void
setAttribute(String
a String specifying the name of the attribute
name
,
Object
the Object to be stored
o
)

Implements javax.servlet.ServletRequest.setAttribute.

The default behavior of this method is to return setAttribute(String name, Object o) on the wrapped request object.
public void
setCharacterEncoding(String
String containing the name of the character encoding.
enc
)

Implements javax.servlet.ServletRequest.setCharacterEncoding.

The default behavior of this method is to set the character encoding on the wrapped request object.
public void
setRequest(ServletRequest
the ServletRequest to be installed
request
)

Sets the request object being wrapped.

public AsyncContext

Returns:

the (re)initialized AsyncContext
startAsync
()

Implements javax.servlet.ServletRequest.startAsync.

The default behavior of this method is to invoke ServletRequest#startAsync on the wrapped request object.
public AsyncContext

Returns:

the (re)initialized AsyncContext
startAsync
(ServletRequest
the ServletRequest used to initialize the AsyncContext
servletRequest
,
ServletResponse
the ServletResponse used to initialize the AsyncContext
servletResponse
)

Implements javax.servlet.ServletRequest.startAsync.

The default behavior of this method is to invoke ServletRequest#startAsync(ServletRequest, ServletResponse) on the wrapped request object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

requestback to summary
private ServletRequest request

Constructor Detail

ServletRequestWrapperback to summary
public ServletRequestWrapper(ServletRequest request)

Creates a ServletRequest adaptor wrapping the given request object.

Parameters
request:ServletRequest

the ServletRequest to be wrapped

Exceptions
IllegalArgumentException:
if the request is null

Method Detail

getAsyncContextback to summary
public AsyncContext getAsyncContext()

Implements javax.servlet.ServletRequest.getAsyncContext.

Gets the AsyncContext that was created or reinitialized by the most recent invocation of startAsync or startAsync(ServletRequest, ServletResponse) on the wrapped request.

Returns:AsyncContext

the AsyncContext that was created or reinitialized by the most recent invocation of startAsync or startAsync(ServletRequest, ServletResponse) on the wrapped request

Exceptions
IllegalStateException:
if this request has not been put into asynchronous mode, i.e., if neither startAsync nor startAsync(ServletRequest, ServletResponse) has been called
Since
Servlet 3.0
See Also
ServletRequest#getAsyncContext
getAttributeback to summary
public Object getAttribute(String name)

Implements javax.servlet.ServletRequest.getAttribute.

The default behavior of this method is to call getAttribute(String name) on the wrapped request object.

Parameters
name:String

Doc from javax.servlet.ServletRequest.getAttribute.

a String specifying the name of the attribute

Returns:Object

Doc from javax.servlet.ServletRequest.getAttribute.

an Object containing the value of the attribute, or null if the attribute does not exist

getAttributeNamesback to summary
public Enumeration<String> getAttributeNames()

Implements javax.servlet.ServletRequest.getAttributeNames.

The default behavior of this method is to return getAttributeNames() on the wrapped request object.

Returns:Enumeration<String>

Doc from javax.servlet.ServletRequest.getAttributeNames.

an Enumeration of strings containing the names of the request's attributes

getCharacterEncodingback to summary
public String getCharacterEncoding()

Implements javax.servlet.ServletRequest.getCharacterEncoding.

The default behavior of this method is to return getCharacterEncoding() on the wrapped request object.

Returns:String

Doc from javax.servlet.ServletRequest.getCharacterEncoding.

a String containing the name of the character encoding, or null if the request does not specify a character encoding

getContentLengthback to summary
public int getContentLength()

Implements javax.servlet.ServletRequest.getContentLength.

The default behavior of this method is to return getContentLength() on the wrapped request object.

Returns:int

Doc from javax.servlet.ServletRequest.getContentLength.

an integer containing the length of the request body or -1 if the length is not known or is greater than Integer.MAX_VALUE.

getContentLengthLongback to summary
public long getContentLengthLong()

Implements javax.servlet.ServletRequest.getContentLengthLong.

The default behavior of this method is to return getContentLengthLong() on the wrapped request object.

Returns:long

Doc from javax.servlet.ServletRequest.getContentLengthLong.

a long containing the length of the request body or -1L if the length is not known

Since
Servlet 3.1
getContentTypeback to summary
public String getContentType()

Implements javax.servlet.ServletRequest.getContentType.

The default behavior of this method is to return getContentType() on the wrapped request object.

Returns:String

Doc from javax.servlet.ServletRequest.getContentType.

a String containing the name of the MIME type of the request, or null if the type is not known

getDispatcherTypeback to summary
public DispatcherType getDispatcherType()

Implements javax.servlet.ServletRequest.getDispatcherType.

Gets the dispatcher type of the wrapped request.

Returns:DispatcherType

the dispatcher type of the wrapped request

Since
Servlet 3.0
See Also
ServletRequest#getDispatcherType
getInputStreamback to summary
public ServletInputStream getInputStream() throws IOException

Implements javax.servlet.ServletRequest.getInputStream.

The default behavior of this method is to return getInputStream() on the wrapped request object.

Returns:ServletInputStream

Doc from javax.servlet.ServletRequest.getInputStream.

a ServletInputStream object containing the body of the request

Exceptions
IOException:

Doc from javax.servlet.ServletRequest.getInputStream.

if an input or output exception occurred

getLocalAddrback to summary
public String getLocalAddr()

Implements javax.servlet.ServletRequest.getLocalAddr.

The default behavior of this method is to return getLocalAddr() on the wrapped request object.

Returns:String

Doc from javax.servlet.ServletRequest.getLocalAddr.

a String containing the IP address on which the request was received.

Since
Servlet 2.4
getLocaleback to summary
public Locale getLocale()

Implements javax.servlet.ServletRequest.getLocale.

The default behavior of this method is to return getLocale() on the wrapped request object.

Returns:Locale

Doc from javax.servlet.ServletRequest.getLocale.

the preferred Locale for the client

getLocalesback to summary
public Enumeration<Locale> getLocales()

Implements javax.servlet.ServletRequest.getLocales.

The default behavior of this method is to return getLocales() on the wrapped request object.

Returns:Enumeration<Locale>

Doc from javax.servlet.ServletRequest.getLocales.

an Enumeration of preferred Locale objects for the client

getLocalNameback to summary
public String getLocalName()

Implements javax.servlet.ServletRequest.getLocalName.

The default behavior of this method is to return getLocalName() on the wrapped request object.

Returns:String

Doc from javax.servlet.ServletRequest.getLocalName.

a String containing the host name of the IP on which the request was received.

Since
Servlet 2.4
getLocalPortback to summary
public int getLocalPort()

Implements javax.servlet.ServletRequest.getLocalPort.

The default behavior of this method is to return getLocalPort() on the wrapped request object.

Returns:int

Doc from javax.servlet.ServletRequest.getLocalPort.

an integer specifying the port number

Since
Servlet 2.4
getParameterback to summary
public String getParameter(String name)

Implements javax.servlet.ServletRequest.getParameter.

The default behavior of this method is to return getParameter(String name) on the wrapped request object.

Parameters
name:String

Doc from javax.servlet.ServletRequest.getParameter.

a String specifying the name of the parameter

Returns:String

Doc from javax.servlet.ServletRequest.getParameter.

a String representing the single value of the parameter

getParameterMapback to summary
public Map<String, String[]> getParameterMap()

Implements javax.servlet.ServletRequest.getParameterMap.

The default behavior of this method is to return getParameterMap() on the wrapped request object.

Returns:Map<String, String[]>

Doc from javax.servlet.ServletRequest.getParameterMap.

an immutable java.util.Map containing parameter names as keys and parameter values as map values. The keys in the parameter map are of type String. The values in the parameter map are of type String array.

getParameterNamesback to summary
public Enumeration<String> getParameterNames()

Implements javax.servlet.ServletRequest.getParameterNames.

The default behavior of this method is to return getParameterNames() on the wrapped request object.

Returns:Enumeration<String>

Doc from javax.servlet.ServletRequest.getParameterNames.

an Enumeration of String objects, each String containing the name of a request parameter; or an empty Enumeration if the request has no parameters

getParameterValuesback to summary
public String[] getParameterValues(String name)

Implements javax.servlet.ServletRequest.getParameterValues.

The default behavior of this method is to return getParameterValues(String name) on the wrapped request object.

Parameters
name:String

Doc from javax.servlet.ServletRequest.getParameterValues.

a String containing the name of the parameter whose value is requested

Returns:String[]

Doc from javax.servlet.ServletRequest.getParameterValues.

an array of String objects containing the parameter's values

getProtocolback to summary
public String getProtocol()

Implements javax.servlet.ServletRequest.getProtocol.

The default behavior of this method is to return getProtocol() on the wrapped request object.

Returns:String

Doc from javax.servlet.ServletRequest.getProtocol.

a String containing the protocol name and version number

getReaderback to summary
public BufferedReader getReader() throws IOException

Implements javax.servlet.ServletRequest.getReader.

The default behavior of this method is to return getReader() on the wrapped request object.

Returns:BufferedReader

Doc from javax.servlet.ServletRequest.getReader.

a BufferedReader containing the body of the request

Exceptions
IOException:

Doc from javax.servlet.ServletRequest.getReader.

if an input or output exception occurred

getRealPathback to summary
public String getRealPath(String path)

Implements javax.servlet.ServletRequest.getRealPath.

Deprecated

As of Version 2.1 of the Java Servlet API, use ServletContext#getRealPath instead

The default behavior of this method is to return getRealPath(String path) on the wrapped request object.

Parameters
path:String

Doc from javax.servlet.ServletRequest.getRealPath.

the path for which the real path is to be returned.

Returns:String

Doc from javax.servlet.ServletRequest.getRealPath.

the real path, or null if the translation cannot be performed.

Annotations
@Deprecated
getRemoteAddrback to summary
public String getRemoteAddr()

Implements javax.servlet.ServletRequest.getRemoteAddr.

The default behavior of this method is to return getRemoteAddr() on the wrapped request object.

Returns:String

Doc from javax.servlet.ServletRequest.getRemoteAddr.

a String containing the IP address of the client that sent the request

getRemoteHostback to summary
public String getRemoteHost()

Implements javax.servlet.ServletRequest.getRemoteHost.

The default behavior of this method is to return getRemoteHost() on the wrapped request object.

Returns:String

Doc from javax.servlet.ServletRequest.getRemoteHost.

a String containing the fully qualified name of the client

getRemotePortback to summary
public int getRemotePort()

Implements javax.servlet.ServletRequest.getRemotePort.

The default behavior of this method is to return getRemotePort() on the wrapped request object.

Returns:int

Doc from javax.servlet.ServletRequest.getRemotePort.

an integer specifying the port number

Since
Servlet 2.4
getRequestback to summary
public ServletRequest getRequest()

Return the wrapped request object.

Returns:ServletRequest

the wrapped ServletRequest

getRequestDispatcherback to summary
public RequestDispatcher getRequestDispatcher(String path)

Implements javax.servlet.ServletRequest.getRequestDispatcher.

The default behavior of this method is to return getRequestDispatcher(String path) on the wrapped request object.

Parameters
path:String

Doc from javax.servlet.ServletRequest.getRequestDispatcher.

a String specifying the pathname to the resource. If it is relative, it must be relative against the current servlet.

Returns:RequestDispatcher

Doc from javax.servlet.ServletRequest.getRequestDispatcher.

a RequestDispatcher object that acts as a wrapper for the resource at the specified path, or null if the servlet container cannot return a RequestDispatcher

getSchemeback to summary
public String getScheme()

Implements javax.servlet.ServletRequest.getScheme.

The default behavior of this method is to return getScheme() on the wrapped request object.

Returns:String

Doc from javax.servlet.ServletRequest.getScheme.

a String containing the name of the scheme used to make this request

getServerNameback to summary
public String getServerName()

Implements javax.servlet.ServletRequest.getServerName.

The default behavior of this method is to return getServerName() on the wrapped request object.

Returns:String

Doc from javax.servlet.ServletRequest.getServerName.

a String containing the name of the server

getServerPortback to summary
public int getServerPort()

Implements javax.servlet.ServletRequest.getServerPort.

The default behavior of this method is to return getServerPort() on the wrapped request object.

Returns:int

Doc from javax.servlet.ServletRequest.getServerPort.

an integer specifying the port number

getServletContextback to summary
public ServletContext getServletContext()

Implements javax.servlet.ServletRequest.getServletContext.

Gets the servlet context to which the wrapped servlet request was last dispatched.

Returns:ServletContext

the servlet context to which the wrapped servlet request was last dispatched

Since
Servlet 3.0
isAsyncStartedback to summary
public boolean isAsyncStarted()

Implements javax.servlet.ServletRequest.isAsyncStarted.

Checks if the wrapped request has been put into asynchronous mode.

Returns:boolean

true if this request has been put into asynchronous mode, false otherwise

Since
Servlet 3.0
See Also
ServletRequest#isAsyncStarted
isAsyncSupportedback to summary
public boolean isAsyncSupported()

Implements javax.servlet.ServletRequest.isAsyncSupported.

Checks if the wrapped request supports asynchronous operation.

Returns:boolean

true if this request supports asynchronous operation, false otherwise

Since
Servlet 3.0
See Also
ServletRequest#isAsyncSupported
isSecureback to summary
public boolean isSecure()

Implements javax.servlet.ServletRequest.isSecure.

The default behavior of this method is to return isSecure() on the wrapped request object.

Returns:boolean

Doc from javax.servlet.ServletRequest.isSecure.

a boolean indicating if the request was made using a secure channel

isWrapperForback to summary
public boolean isWrapperFor(ServletRequest wrapped)

Checks (recursively) if this ServletRequestWrapper wraps the given ServletRequest instance.

Parameters
wrapped:ServletRequest

the ServletRequest instance to search for

Returns:boolean

true if this ServletRequestWrapper wraps the given ServletRequest instance, false otherwise

Since
Servlet 3.0
isWrapperForback to summary
public boolean isWrapperFor(Class<?> wrappedType)

Checks (recursively) if this ServletRequestWrapper wraps a ServletRequest of the given class type.

Parameters
wrappedType:Class<?>

the ServletRequest class type to search for

Returns:boolean

true if this ServletRequestWrapper wraps a ServletRequest of the given class type, false otherwise

Exceptions
IllegalArgumentException:
if the given class does not implement ServletRequest
Since
Servlet 3.0
removeAttributeback to summary
public void removeAttribute(String name)

Implements javax.servlet.ServletRequest.removeAttribute.

The default behavior of this method is to call removeAttribute(String name) on the wrapped request object.

Parameters
name:String

Doc from javax.servlet.ServletRequest.removeAttribute.

a String specifying the name of the attribute to remove

setAttributeback to summary
public void setAttribute(String name, Object o)

Implements javax.servlet.ServletRequest.setAttribute.

The default behavior of this method is to return setAttribute(String name, Object o) on the wrapped request object.

Parameters
name:String

Doc from javax.servlet.ServletRequest.setAttribute.

a String specifying the name of the attribute

o:Object

Doc from javax.servlet.ServletRequest.setAttribute.

the Object to be stored

setCharacterEncodingback to summary
public void setCharacterEncoding(String enc) throws UnsupportedEncodingException

Implements javax.servlet.ServletRequest.setCharacterEncoding.

The default behavior of this method is to set the character encoding on the wrapped request object.

Parameters
enc:String

Doc from javax.servlet.ServletRequest.setCharacterEncoding.

String containing the name of the character encoding.

Exceptions
UnsupportedEncodingException:

Doc from javax.servlet.ServletRequest.setCharacterEncoding.

if this ServletRequest is still in a state where a character encoding may be set, but the specified encoding is invalid

setRequestback to summary
public void setRequest(ServletRequest request)

Sets the request object being wrapped.

Parameters
request:ServletRequest

the ServletRequest to be installed

Exceptions
IllegalArgumentException:
if the request is null.
startAsyncback to summary
public AsyncContext startAsync() throws IllegalStateException

Implements javax.servlet.ServletRequest.startAsync.

The default behavior of this method is to invoke ServletRequest#startAsync on the wrapped request object.

Returns:AsyncContext

the (re)initialized AsyncContext

Exceptions
IllegalStateException:
if the request is within the scope of a filter or servlet that does not support asynchronous operations (that is, isAsyncSupported returns false), or if this method is called again without any asynchronous dispatch (resulting from one of the AsyncContext#dispatch methods), is called outside the scope of any such dispatch, or is called again within the scope of the same dispatch, or if the response has already been closed
Since
Servlet 3.0
See Also
ServletRequest#startAsync
startAsyncback to summary
public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException

Implements javax.servlet.ServletRequest.startAsync.

The default behavior of this method is to invoke ServletRequest#startAsync(ServletRequest, ServletResponse) on the wrapped request object.

Parameters
servletRequest:ServletRequest

the ServletRequest used to initialize the AsyncContext

servletResponse:ServletResponse

the ServletResponse used to initialize the AsyncContext

Returns:AsyncContext

the (re)initialized AsyncContext

Exceptions
IllegalStateException:
if the request is within the scope of a filter or servlet that does not support asynchronous operations (that is, isAsyncSupported returns false), or if this method is called again without any asynchronous dispatch (resulting from one of the AsyncContext#dispatch methods), is called outside the scope of any such dispatch, or is called again within the scope of the same dispatch, or if the response has already been closed
Since
Servlet 3.0
See Also
ServletRequest#startAsync(ServletRequest, ServletResponse)