Apache Tomcat 7.0.28

org.apache.catalina.connector
Class Request

java.lang.Object
  extended by org.apache.catalina.connector.Request
All Implemented Interfaces:
HttpServletRequest, ServletRequest

public class Request
extends Object
implements HttpServletRequest

Wrapper object for the Coyote request.

Version:
$Id: Request.java 1335733 2012-05-08 20:07:23Z markt $
Author:
Remy Maucherat, Craig R. McClanahan

Field Summary
protected  AsyncContextImpl asyncContext
          AsyncContext
protected  Boolean asyncSupported
           
protected  HashMap<String,Object> attributes
          The attributes associated with this Request, keyed by attribute name.
protected  String authType
          Authentication type.
protected static int CACHED_POST_LEN
          Post data buffer.
protected  boolean comet
          Comet state
protected  Connector connector
          Associated Catalina connector.
protected  Context context
          Associated context.
protected  Cookie[] cookies
          The set of cookies associated with this Request.
protected  boolean cookiesParsed
          Cookies parsed flag.
protected  Request coyoteRequest
          Coyote request.
protected static Locale defaultLocale
          The default Locale if none are specified.
protected  CometEventImpl event
          Associated event.
protected  RequestFacade facade
          The facade associated with this request.
protected  FilterChain filterChain
          Filter chain associated with the request.
protected  SimpleDateFormat[] formats
          The set of SimpleDateFormat formats to use in getDateHeader().
protected static TimeZone GMT_ZONE
           
protected static String info
          Descriptive information about this Request implementation.
protected  InputBuffer inputBuffer
          The associated input buffer.
protected  CoyoteInputStream inputStream
          ServletInputStream.
protected  DispatcherType internalDispatcherType
          The current dispatcher type.
protected  String localAddr
          Local address
protected  ArrayList<Locale> locales
          The preferred Locales associated with this Request.
protected  boolean localesParsed
          Parse locales.
protected  String localName
          Local address
protected  int localPort
          Local port
protected  MappingData mappingData
          Mapping data.
protected  ParameterMap<String,String[]> parameterMap
          Hash map used in the getParametersMap method.
protected  boolean parametersParsed
          Request parameters parsed flag.
protected  Collection<Part> parts
          The parts, if any, uploaded with this request.
protected  Exception partsParseException
          The exception thrown, if any when parsing the parts.
protected  Map<String,String> pathParameters
          Path parameters
protected  byte[] postData
           
protected  CoyoteReader reader
          Reader.
protected  String remoteAddr
          Remote address.
protected  String remoteHost
          Remote host.
protected  int remotePort
          Remote port
protected  Object requestDispatcherPath
          The current request dispatcher path.
protected  boolean requestedSessionCookie
          Was the requested session ID received in a cookie?
protected  String requestedSessionId
          The requested session ID (if any) for this request.
protected  boolean requestedSessionSSL
          Was the requested session ID obtained from the SSL session?
protected  boolean requestedSessionURL
          Was the requested session ID received in a URL?
protected  Response response
          The response with which this request is associated.
protected  boolean secure
          Secure flag.
protected  Session session
          The currently active session for this request.
protected  boolean sessionParsed
          Deprecated. 
protected static StringManager sm
          The string manager for this package.
protected  boolean sslAttributesParsed
          Flag that indicates if SSL attributes have been parsed to improve performance for applications (usually frameworks) that make multiple calls to getAttributeNames().
protected  Subject subject
          The Subject associated with the current AccessControllerContext
protected  B2CConverter URIConverter
          URI byte to char converter (not recycled).
protected  Principal userPrincipal
          User principal.
protected  boolean usingInputStream
          Using stream flag.
protected  boolean usingReader
          Using writer flag.
protected  Wrapper wrapper
          Associated wrapper.
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
Request()
           
 
Method Summary
 void addCookie(Cookie cookie)
          Add a Cookie to the set of Cookies associated with this Request.
 void addLocale(Locale locale)
          Add a Locale to the set of preferred Locales for this Request.
 void addParameter(String name, String[] values)
          Deprecated. 
protected  void addPathParameter(String name, String value)
           
 boolean authenticate(HttpServletResponse response)
           
 void changeSessionId(String newSessionId)
          Change the ID of the session that this request is associated with.
protected  void checkSwallowInput()
          Disable swallowing of remaining input if configured
 void clearCookies()
          Clear the collection of Cookies associated with this Request.
 void clearEncoders()
          Clear cached encoders (to save memory for Comet requests).
 void clearHeaders()
          Deprecated. 
 void clearLocales()
          Clear the collection of Locales associated with this Request.
 void clearParameters()
          Deprecated. 
 void cometClose()
           
 ServletInputStream createInputStream()
          Create and return a ServletInputStream to read the content associated with this Request.
protected  Session doGetSession(boolean create)
           
 void doUpgrade(UpgradeInbound inbound)
           
 void finishRequest()
          Perform whatever actions are required to flush and close the input stream or reader, in a single operation.
 AsyncContext getAsyncContext()
           
 Object getAttribute(String name)
          Return the specified request attribute if it exists; otherwise, return null.
 Enumeration<String> getAttributeNames()
          Return the names of all request attributes for this Request, or an empty Enumeration if there are none.
 String getAuthType()
          Return the authentication type used for this Request.
 boolean getAvailable()
          Return true if bytes are available.
 String getCharacterEncoding()
          Return the character encoding for this Request.
 Connector getConnector()
          Return the Connector through which this Request was received.
 int getContentLength()
          Return the content length for this Request.
 String getContentType()
          Return the content type for this Request.
 Context getContext()
          Return the Context within which this Request is being processed.
 String getContextPath()
          Return the portion of the request URI used to select the Context of the Request.
 MessageBytes getContextPathMB()
          Deprecated. 
 Cookie[] getCookies()
          Return the set of Cookies received with this Request.
 Request getCoyoteRequest()
          Get the Coyote request.
 long getDateHeader(String name)
          Return the value of the specified date header, if any; otherwise return -1.
 String getDecodedRequestURI()
          Get the decoded request URI.
 MessageBytes getDecodedRequestURIMB()
          Deprecated. 
 DispatcherType getDispatcherType()
           
 CometEventImpl getEvent()
          Get the event associated with the request.
 FilterChain getFilterChain()
          Get filter chain associated with the request.
 String getHeader(String name)
          Return the first value of the specified header, if any; otherwise, return null
 Enumeration<String> getHeaderNames()
          Return the names of all headers received with this request.
 Enumeration<String> getHeaders(String name)
          Return all of the values of the specified header, if any; otherwise, return an empty enumeration.
 Host getHost()
          Return the Host within which this Request is being processed.
 String getInfo()
          Return descriptive information about this Request implementation and the corresponding version number, in the format <description>/<version>.
 ServletInputStream getInputStream()
          Return the servlet input stream for this Request.
 int getIntHeader(String name)
          Return the value of the specified header as an integer, or -1 if there is no such header for this request.
 String getLocalAddr()
          Returns the Internet Protocol (IP) address of the interface on which the request was received.
 Locale getLocale()
          Return the preferred Locale that the client will accept content in, based on the value for the first Accept-Language header that was encountered.
 Enumeration<Locale> getLocales()
          Return the set of preferred Locales that the client will accept content in, based on the values for any Accept-Language headers that were encountered.
 String getLocalName()
          Returns the host name of the Internet Protocol (IP) interface on which the request was received.
 int getLocalPort()
          Returns the Internet Protocol (IP) port number of the interface on which the request was received.
 MappingData getMappingData()
          Return mapping data.
 String getMethod()
          Return the HTTP request method used in this Request.
 Object getNote(String name)
          Return the object bound with the specified name to the internal notes for this request, or null if no such binding exists.
 Iterator<String> getNoteNames()
          Deprecated. 
 String getParameter(String name)
          Return the value of the specified request parameter, if any; otherwise, return null.
 Map<String,String[]> getParameterMap()
          Returns a Map of the parameters of this request.
 Enumeration<String> getParameterNames()
          Return the names of all defined request parameters for this request.
 String[] getParameterValues(String name)
          Return the defined values for the specified request parameter, if any; otherwise, return null.
 Part getPart(String name)
          Gets the named Part or null if the Part does not exist.
 Collection<Part> getParts()
          Return a collection of all uploaded Parts.
 String getPathInfo()
          Return the path information associated with this Request.
 MessageBytes getPathInfoMB()
          Deprecated. 
protected  String getPathParameter(String name)
           
 String getPathTranslated()
          Return the extra path information for this request, translated to a real path.
 Principal getPrincipal()
          Return the principal that has been authenticated for this Request.
 String getProtocol()
          Return the protocol and version used to make this Request.
 String getQueryString()
          Return the query string associated with this request.
 BufferedReader getReader()
          Read the Reader wrapping the input stream for this Request.
 String getRealPath(String path)
          Deprecated. As of version 2.1 of the Java Servlet API, use ServletContext.getRealPath().
 String getRemoteAddr()
          Return the remote IP address making this Request.
 String getRemoteHost()
          Return the remote host name making this Request.
 int getRemotePort()
          Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.
 String getRemoteUser()
          Return the name of the remote user that has been authenticated for this Request.
 HttpServletRequest getRequest()
          Return the ServletRequest for which this object is the facade.
 RequestDispatcher getRequestDispatcher(String path)
          Return a RequestDispatcher that wraps the resource at the specified path, which may be interpreted as relative to the current request path.
 String getRequestedSessionId()
          Return the session identifier included in this request, if any.
 MessageBytes getRequestPathMB()
          Get the request path.
 String getRequestURI()
          Return the request URI for this request.
 StringBuffer getRequestURL()
          Reconstructs the URL the client used to make the request.
 Response getResponse()
          Return the Response with which this Request is associated.
 String getScheme()
          Return the scheme used to make this Request.
 String getServerName()
          Return the server name responding to this Request.
 int getServerPort()
          Return the server port responding to this Request.
 ServletContext getServletContext()
           
 String getServletPath()
          Return the portion of the request URI used to select the servlet that will process this request.
 MessageBytes getServletPathMB()
          Deprecated. 
 HttpSession getSession()
          Return the session associated with this Request, creating one if necessary.
 HttpSession getSession(boolean create)
          Return the session associated with this Request, creating one if necessary and requested.
 Session getSessionInternal()
          Return the session associated with this Request, creating one if necessary.
 Session getSessionInternal(boolean create)
          Return the session associated with this Request, creating one if necessary and requested.
 InputStream getStream()
          Return the input stream associated with this Request.
protected  B2CConverter getURIConverter()
          Return the URI converter.
 Principal getUserPrincipal()
          Return the principal that has been authenticated for this Request.
 Wrapper getWrapper()
          Return the Wrapper within which this Request is being processed.
protected static boolean isAlpha(String value)
           
 boolean isAsync()
           
 boolean isAsyncDispatching()
           
 boolean isAsyncStarted()
           
 boolean isAsyncSupported()
           
 boolean isComet()
          Return true if the current request is handling Comet traffic.
 boolean isParametersParsed()
          return true if we have parsed parameters
protected  boolean isProcessing()
          Deprecated. 
 boolean isRequestedSessionIdFromCookie()
          Return true if the session identifier included in this request came from a cookie.
 boolean isRequestedSessionIdFromSSL()
          Deprecated. 
 boolean isRequestedSessionIdFromUrl()
          Deprecated. As of Version 2.1 of the Java Servlet API, use isRequestedSessionIdFromURL() instead.
 boolean isRequestedSessionIdFromURL()
          Return true if the session identifier included in this request came from the request URI.
 boolean isRequestedSessionIdValid()
          Return true if the session identifier included in this request identifies a valid session.
 boolean isSecure()
          Was this request received on a secure connection?
 boolean isUserInRole(String role)
          Return true if the authenticated user principal possesses the specified role name.
 void login(String username, String password)
          
 void logout()
          
protected  void parseCookies()
          Parse cookies.
protected  void parseLocales()
          Parse request locales.
protected  void parseLocalesHeader(String value)
          Parse accept-language header value.
protected  void parseParameters()
          Parse request parameters.
 boolean read()
          Clear cached encoders (to save memory for Comet requests).
protected  byte[] readChunkedPostBody()
          Read chunked post body.
protected  int readPostBody(byte[] body, int len)
          Read post body in an array.
 void recycle()
          Release all object references, and initialize instance variables, in preparation for reuse of this object.
 void removeAttribute(String name)
          Remove the specified request attribute if it exists.
 void removeNote(String name)
          Remove any object bound to the specified name in the internal notes for this request.
 void setAsyncSupported(boolean asyncSupported)
           
 void setAttribute(String name, Object value)
          Set the specified request attribute to the specified value.
 void setAuthType(String type)
          Set the authentication type used for this request, if any; otherwise set the type to null.
 void setCharacterEncoding(String enc)
          Overrides the name of the character encoding used in the body of this request.
 void setComet(boolean comet)
          Set comet state.
 void setCometTimeout(long timeout)
           
 void setConnector(Connector connector)
          Set the Connector through which this Request was received.
 void setContext(Context context)
          Set the Context within which this Request is being processed.
 void setContextPath(String path)
          Deprecated. 
 void setCookies(Cookie[] cookies)
          Deprecated. 
 void setCoyoteRequest(Request coyoteRequest)
          Set the Coyote request.
 void setFilterChain(FilterChain filterChain)
          Set filter chain associated with the request.
 void setHost(Host host)
          Deprecated. 
 void setLocalPort(int port)
          Set the port number of the server to process this request.
 void setNote(String name, Object value)
          Bind an object to a specified name in the internal notes associated with this request, replacing any existing binding for this name.
 void setPathInfo(String path)
          Set the path information for this Request.
 void setRemoteAddr(String remoteAddr)
          Set the IP address of the remote client associated with this Request.
 void setRemoteHost(String remoteHost)
          Set the fully qualified name of the remote client associated with this Request.
 void setRequestedSessionCookie(boolean flag)
          Set a flag indicating whether or not the requested session ID for this request came in through a cookie.
 void setRequestedSessionId(String id)
          Set the requested session ID for this request.
 void setRequestedSessionSSL(boolean flag)
          Set a flag indicating whether or not the requested session ID for this request came in through SSL.
 void setRequestedSessionURL(boolean flag)
          Set a flag indicating whether or not the requested session ID for this request came in through a URL.
 void setResponse(Response response)
          Set the Response with which this Request is associated.
 void setSecure(boolean secure)
          Set the value to be returned by isSecure() for this Request.
 void setServerName(String name)
          Deprecated. 
 void setServerPort(int port)
          Set the port number of the server to process this request.
 void setServletPath(String path)
          Deprecated. 
protected  void setURIConverter(B2CConverter URIConverter)
          Set the URI converter.
 void setUserPrincipal(Principal principal)
          Set the Principal who has been authenticated for this Request.
 void setWrapper(Wrapper wrapper)
          Set the Wrapper within which this Request is being processed.
 AsyncContext startAsync()
           
 AsyncContext startAsync(ServletRequest request, ServletResponse response)
           
protected  String unescape(String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

coyoteRequest

protected Request coyoteRequest
Coyote request.


GMT_ZONE

protected static final TimeZone GMT_ZONE

sm

protected static final StringManager sm
The string manager for this package.


cookies

protected Cookie[] cookies
The set of cookies associated with this Request.


formats

protected SimpleDateFormat[] formats
The set of SimpleDateFormat formats to use in getDateHeader(). Notice that because SimpleDateFormat is not thread-safe, we can't declare formats[] as a static variable.


defaultLocale

protected static Locale defaultLocale
The default Locale if none are specified.


attributes

protected HashMap<String,Object> attributes
The attributes associated with this Request, keyed by attribute name.


sslAttributesParsed

protected boolean sslAttributesParsed
Flag that indicates if SSL attributes have been parsed to improve performance for applications (usually frameworks) that make multiple calls to getAttributeNames().


locales

protected ArrayList<Locale> locales
The preferred Locales associated with this Request.


authType

protected String authType
Authentication type.


event

protected CometEventImpl event
Associated event.


comet

protected boolean comet
Comet state


internalDispatcherType

protected DispatcherType internalDispatcherType
The current dispatcher type.


inputBuffer

protected InputBuffer inputBuffer
The associated input buffer.


inputStream

protected CoyoteInputStream inputStream
ServletInputStream.


reader

protected CoyoteReader reader
Reader.


usingInputStream

protected boolean usingInputStream
Using stream flag.


usingReader

protected boolean usingReader
Using writer flag.


userPrincipal

protected Principal userPrincipal
User principal.


sessionParsed

@Deprecated
protected boolean sessionParsed
Deprecated. 
Session parsed flag.


parametersParsed

protected boolean parametersParsed
Request parameters parsed flag.


cookiesParsed

protected boolean cookiesParsed
Cookies parsed flag.


secure

protected boolean secure
Secure flag.


subject

protected transient Subject subject
The Subject associated with the current AccessControllerContext


CACHED_POST_LEN

protected static int CACHED_POST_LEN
Post data buffer.


postData

protected byte[] postData

parameterMap

protected ParameterMap<String,String[]> parameterMap
Hash map used in the getParametersMap method.


parts

protected Collection<Part> parts
The parts, if any, uploaded with this request.


partsParseException

protected Exception partsParseException
The exception thrown, if any when parsing the parts.


session

protected Session session
The currently active session for this request.


requestDispatcherPath

protected Object requestDispatcherPath
The current request dispatcher path.


requestedSessionCookie

protected boolean requestedSessionCookie
Was the requested session ID received in a cookie?


requestedSessionId

protected String requestedSessionId
The requested session ID (if any) for this request.


requestedSessionURL

protected boolean requestedSessionURL
Was the requested session ID received in a URL?


requestedSessionSSL

protected boolean requestedSessionSSL
Was the requested session ID obtained from the SSL session?


localesParsed

protected boolean localesParsed
Parse locales.


localPort

protected int localPort
Local port


remoteAddr

protected String remoteAddr
Remote address.


remoteHost

protected String remoteHost
Remote host.


remotePort

protected int remotePort
Remote port


localAddr

protected String localAddr
Local address


localName

protected String localName
Local address


asyncContext

protected volatile AsyncContextImpl asyncContext
AsyncContext


asyncSupported

protected Boolean asyncSupported

pathParameters

protected Map<String,String> pathParameters
Path parameters


connector

protected Connector connector
Associated Catalina connector.


context

protected Context context
Associated context.


filterChain

protected FilterChain filterChain
Filter chain associated with the request.


info

protected static final String info
Descriptive information about this Request implementation.

See Also:
Constant Field Values

mappingData

protected MappingData mappingData
Mapping data.


facade

protected RequestFacade facade
The facade associated with this request.


response

protected Response response
The response with which this request is associated.


URIConverter

protected B2CConverter URIConverter
URI byte to char converter (not recycled).


wrapper

protected Wrapper wrapper
Associated wrapper.

Constructor Detail

Request

public Request()
Method Detail

setCoyoteRequest

public void setCoyoteRequest(Request coyoteRequest)
Set the Coyote request.

Parameters:
coyoteRequest - The Coyote request

getCoyoteRequest

public Request getCoyoteRequest()
Get the Coyote request.


addPathParameter

protected void addPathParameter(String name,
                                String value)

getPathParameter

protected String getPathParameter(String name)

setAsyncSupported

public void setAsyncSupported(boolean asyncSupported)

recycle

public void recycle()
Release all object references, and initialize instance variables, in preparation for reuse of this object.


isProcessing

@Deprecated
protected boolean isProcessing()
Deprecated. 


clearEncoders

public void clearEncoders()
Clear cached encoders (to save memory for Comet requests).


read

public boolean read()
             throws IOException
Clear cached encoders (to save memory for Comet requests).

Throws:
IOException

getConnector

public Connector getConnector()
Return the Connector through which this Request was received.


setConnector

public void setConnector(Connector connector)
Set the Connector through which this Request was received.

Parameters:
connector - The new connector

getContext

public Context getContext()
Return the Context within which this Request is being processed.


setContext

public void setContext(Context context)
Set the Context within which this Request is being processed. This must be called as soon as the appropriate Context is identified, because it identifies the value to be returned by getContextPath(), and thus enables parsing of the request URI.

Parameters:
context - The newly associated Context

getFilterChain

public FilterChain getFilterChain()
Get filter chain associated with the request.


setFilterChain

public void setFilterChain(FilterChain filterChain)
Set filter chain associated with the request.

Parameters:
filterChain - new filter chain

getHost

public Host getHost()
Return the Host within which this Request is being processed.


setHost

@Deprecated
public void setHost(Host host)
Deprecated. 

Set the Host within which this Request is being processed. This must be called as soon as the appropriate Host is identified, and before the Request is passed to a context.

Parameters:
host - The newly associated Host

getInfo

public String getInfo()
Return descriptive information about this Request implementation and the corresponding version number, in the format <description>/<version>.


getMappingData

public MappingData getMappingData()
Return mapping data.


getRequest

public HttpServletRequest getRequest()
Return the ServletRequest for which this object is the facade. This method must be implemented by a subclass.


getResponse

public Response getResponse()
Return the Response with which this Request is associated.


setResponse

public void setResponse(Response response)
Set the Response with which this Request is associated.

Parameters:
response - The new associated response

getStream

public InputStream getStream()
Return the input stream associated with this Request.


getURIConverter

protected B2CConverter getURIConverter()
Return the URI converter.


setURIConverter

protected void setURIConverter(B2CConverter URIConverter)
Set the URI converter.

Parameters:
URIConverter - the new URI converter

getWrapper

public Wrapper getWrapper()
Return the Wrapper within which this Request is being processed.


setWrapper

public void setWrapper(Wrapper wrapper)
Set the Wrapper within which this Request is being processed. This must be called as soon as the appropriate Wrapper is identified, and before the Request is ultimately passed to an application servlet.

Parameters:
wrapper - The newly associated Wrapper

createInputStream

public ServletInputStream createInputStream()
                                     throws IOException
Create and return a ServletInputStream to read the content associated with this Request.

Throws:
IOException - if an input/output error occurs

finishRequest

public void finishRequest()
                   throws IOException
Perform whatever actions are required to flush and close the input stream or reader, in a single operation.

Throws:
IOException - if an input/output error occurs

getNote

public Object getNote(String name)
Return the object bound with the specified name to the internal notes for this request, or null if no such binding exists.

Parameters:
name - Name of the note to be returned

getNoteNames

@Deprecated
public Iterator<String> getNoteNames()
Deprecated. 

Return an Iterator containing the String names of all notes bindings that exist for this request.


removeNote

public void removeNote(String name)
Remove any object bound to the specified name in the internal notes for this request.

Parameters:
name - Name of the note to be removed

setLocalPort

public void setLocalPort(int port)
Set the port number of the server to process this request.

Parameters:
port - The server port

setNote

public void setNote(String name,
                    Object value)
Bind an object to a specified name in the internal notes associated with this request, replacing any existing binding for this name.

Parameters:
name - Name to which the object should be bound
value - Object to be bound to the specified name

setRemoteAddr

public void setRemoteAddr(String remoteAddr)
Set the IP address of the remote client associated with this Request.

Parameters:
remoteAddr - The remote IP address

setRemoteHost

public void setRemoteHost(String remoteHost)
Set the fully qualified name of the remote client associated with this Request.

Parameters:
remoteHost - The remote host name

setSecure

public void setSecure(boolean secure)
Set the value to be returned by isSecure() for this Request.

Parameters:
secure - The new isSecure value

setServerName

@Deprecated
public void setServerName(String name)
Deprecated. 

Set the name of the server (virtual host) to process this request.

Parameters:
name - The server name

setServerPort

public void setServerPort(int port)
Set the port number of the server to process this request.

Parameters:
port - The server port

getAttribute

public Object getAttribute(String name)
Return the specified request attribute if it exists; otherwise, return null.

Specified by:
getAttribute in interface ServletRequest
Parameters:
name - Name of the request attribute to return
Returns:
an Object containing the value of the attribute, or null if the attribute does not exist

getAttributeNames

public Enumeration<String> getAttributeNames()
Return the names of all request attributes for this Request, or an empty Enumeration if there are none. Note that the attribute names returned will only be those for the attributes set via setAttribute(String, Object). Tomcat internal attributes will not be included although they are accessible via getAttribute(String). The Tomcat internal attributes include: The underlying connector may also expose request attributes. These all have names starting with "org.apache.tomcat" and include: Connector implementations may return some, all or none of these attributes and may also support additional attributes.

Specified by:
getAttributeNames in interface ServletRequest
Returns:
an Enumeration of strings containing the names of the request's attributes

getCharacterEncoding

public String getCharacterEncoding()
Return the character encoding for this Request.

Specified by:
getCharacterEncoding in interface ServletRequest
Returns:
a String containing the name of the character encoding, or null if the request does not specify a character encoding

getContentLength

public int getContentLength()
Return the content length for this Request.

Specified by:
getContentLength in interface ServletRequest
Returns:
an integer containing the length of the request body or -1 if the length is not known

getContentType

public String getContentType()
Return the content type for this Request.

Specified by:
getContentType in interface ServletRequest
Returns:
a String containing the name of the MIME type of the request, or null if the type is not known

getInputStream

public ServletInputStream getInputStream()
                                  throws IOException
Return the servlet input stream for this Request. The default implementation returns a servlet input stream created by createInputStream().

Specified by:
getInputStream in interface ServletRequest
Returns:
a ServletInputStream object containing the body of the request
Throws:
IllegalStateException - if getReader() has already been called for this request
IOException - if an input/output error occurs

getLocale

public Locale getLocale()
Return the preferred Locale that the client will accept content in, based on the value for the first Accept-Language header that was encountered. If the request did not specify a preferred language, the server's default Locale is returned.

Specified by:
getLocale in interface ServletRequest
Returns:
the preferred Locale for the client

getLocales

public Enumeration<Locale> getLocales()
Return the set of preferred Locales that the client will accept content in, based on the values for any Accept-Language headers that were encountered. If the request did not specify a preferred language, the server's default Locale is returned.

Specified by:
getLocales in interface ServletRequest
Returns:
an Enumeration of preferred Locale objects for the client

getParameter

public String getParameter(String name)
Return the value of the specified request parameter, if any; otherwise, return null. If there is more than one value defined, return only the first one.

Specified by:
getParameter in interface ServletRequest
Parameters:
name - Name of the desired request parameter
Returns:
a String representing the single value of the parameter
See Also:
ServletRequest.getParameterValues(java.lang.String)

getParameterMap

public Map<String,String[]> getParameterMap()
Returns a Map of the parameters of this request. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.

Specified by:
getParameterMap in interface ServletRequest
Returns:
A Map containing parameter names as keys and parameter values as map values.

getParameterNames

public Enumeration<String> getParameterNames()
Return the names of all defined request parameters for this request.

Specified by:
getParameterNames in interface ServletRequest
Returns:
an Enumeration of String objects, each String containing the name of a request parameter; or an empty Enumeration if the request has no parameters

getParameterValues

public String[] getParameterValues(String name)
Return the defined values for the specified request parameter, if any; otherwise, return null.

Specified by:
getParameterValues in interface ServletRequest
Parameters:
name - Name of the desired request parameter
Returns:
an array of String objects containing the parameter's values
See Also:
ServletRequest.getParameter(java.lang.String)

getProtocol

public String getProtocol()
Return the protocol and version used to make this Request.

Specified by:
getProtocol in interface ServletRequest
Returns:
a String containing the protocol name and version number

getReader

public BufferedReader getReader()
                         throws IOException
Read the Reader wrapping the input stream for this Request. The default implementation wraps a BufferedReader around the servlet input stream returned by createInputStream().

Specified by:
getReader in interface ServletRequest
Returns:
a BufferedReader containing the body of the request
Throws:
IllegalStateException - if getInputStream() has already been called for this request
IOException - if an input/output error occurs
See Also:
ServletRequest.getInputStream()

getRealPath

@Deprecated
public String getRealPath(String path)
Deprecated. As of version 2.1 of the Java Servlet API, use ServletContext.getRealPath().

Return the real path of the specified virtual path.

Specified by:
getRealPath in interface ServletRequest
Parameters:
path - Path to be translated

getRemoteAddr

public String getRemoteAddr()
Return the remote IP address making this Request.

Specified by:
getRemoteAddr in interface ServletRequest
Returns:
a String containing the IP address of the client that sent the request

getRemoteHost

public String getRemoteHost()
Return the remote host name making this Request.

Specified by:
getRemoteHost in interface ServletRequest
Returns:
a String containing the fully qualified name of the client

getRemotePort

public int getRemotePort()
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.

Specified by:
getRemotePort in interface ServletRequest
Returns:
an integer specifying the port number

getLocalName

public String getLocalName()
Returns the host name of the Internet Protocol (IP) interface on which the request was received.

Specified by:
getLocalName in interface ServletRequest
Returns:
a String containing the host name of the IP on which the request was received.

getLocalAddr

public String getLocalAddr()
Returns the Internet Protocol (IP) address of the interface on which the request was received.

Specified by:
getLocalAddr in interface ServletRequest
Returns:
a String containing the IP address on which the request was received.

getLocalPort

public int getLocalPort()
Returns the Internet Protocol (IP) port number of the interface on which the request was received.

Specified by:
getLocalPort in interface ServletRequest
Returns:
an integer specifying the port number

getRequestDispatcher

public RequestDispatcher getRequestDispatcher(String path)
Return a RequestDispatcher that wraps the resource at the specified path, which may be interpreted as relative to the current request path.

Specified by:
getRequestDispatcher in interface ServletRequest
Parameters:
path - Path of the resource to be wrapped
Returns:
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
See Also:
RequestDispatcher, ServletContext.getRequestDispatcher(java.lang.String)

getScheme

public String getScheme()
Return the scheme used to make this Request.

Specified by:
getScheme in interface ServletRequest
Returns:
a String containing the name of the scheme used to make this request

getServerName

public String getServerName()
Return the server name responding to this Request.

Specified by:
getServerName in interface ServletRequest
Returns:
a String containing the name of the server

getServerPort

public int getServerPort()
Return the server port responding to this Request.

Specified by:
getServerPort in interface ServletRequest
Returns:
an integer specifying the port number

isSecure

public boolean isSecure()
Was this request received on a secure connection?

Specified by:
isSecure in interface ServletRequest
Returns:
a boolean indicating if the request was made using a secure channel

removeAttribute

public void removeAttribute(String name)
Remove the specified request attribute if it exists.

Specified by:
removeAttribute in interface ServletRequest
Parameters:
name - Name of the request attribute to remove

setAttribute

public void setAttribute(String name,
                         Object value)
Set the specified request attribute to the specified value.

Specified by:
setAttribute in interface ServletRequest
Parameters:
name - Name of the request attribute to set
value - The associated value

setCharacterEncoding

public void setCharacterEncoding(String enc)
                          throws UnsupportedEncodingException
Overrides the name of the character encoding used in the body of this request. This method must be called prior to reading request parameters or reading input using getReader().

Specified by:
setCharacterEncoding in interface ServletRequest
Parameters:
enc - The character encoding to be used
Throws:
UnsupportedEncodingException - if the specified encoding is not supported
Since:
Servlet 2.3

getServletContext

public ServletContext getServletContext()
Specified by:
getServletContext in interface ServletRequest
Returns:
TODO

startAsync

public AsyncContext startAsync()
Specified by:
startAsync in interface ServletRequest
Returns:
TODO

startAsync

public AsyncContext startAsync(ServletRequest request,
                               ServletResponse response)
Specified by:
startAsync in interface ServletRequest
Returns:
TODO

isAsyncStarted

public boolean isAsyncStarted()
Specified by:
isAsyncStarted in interface ServletRequest
Returns:
TODO

isAsyncDispatching

public boolean isAsyncDispatching()

isAsync

public boolean isAsync()

isAsyncSupported

public boolean isAsyncSupported()
Specified by:
isAsyncSupported in interface ServletRequest
Returns:
TODO

getAsyncContext

public AsyncContext getAsyncContext()
Specified by:
getAsyncContext in interface ServletRequest
Returns:
TODO

getDispatcherType

public DispatcherType getDispatcherType()
Specified by:
getDispatcherType in interface ServletRequest
Returns:
TODO

addCookie

public void addCookie(Cookie cookie)
Add a Cookie to the set of Cookies associated with this Request.

Parameters:
cookie - The new cookie

addLocale

public void addLocale(Locale locale)
Add a Locale to the set of preferred Locales for this Request. The first added Locale will be the first one returned by getLocales().

Parameters:
locale - The new preferred Locale

addParameter

@Deprecated
public void addParameter(String name,
                                    String[] values)
Deprecated. 

Add a parameter name and corresponding set of values to this Request. (This is used when restoring the original request on a form based login).

Parameters:
name - Name of this request parameter
values - Corresponding values for this request parameter

clearCookies

public void clearCookies()
Clear the collection of Cookies associated with this Request.


clearHeaders

@Deprecated
public void clearHeaders()
Deprecated. 

Clear the collection of Headers associated with this Request.


clearLocales

public void clearLocales()
Clear the collection of Locales associated with this Request.


clearParameters

@Deprecated
public void clearParameters()
Deprecated. 

Clear the collection of parameters associated with this Request.


setAuthType

public void setAuthType(String type)
Set the authentication type used for this request, if any; otherwise set the type to null. Typical values are "BASIC", "DIGEST", or "SSL".

Parameters:
type - The authentication type used

setContextPath

@Deprecated
public void setContextPath(String path)
Deprecated. 

Set the context path for this Request. This will normally be called when the associated Context is mapping the Request to a particular Wrapper.

Parameters:
path - The context path

setPathInfo

public void setPathInfo(String path)
Set the path information for this Request. This will normally be called when the associated Context is mapping the Request to a particular Wrapper.

Parameters:
path - The path information

setRequestedSessionCookie

public void setRequestedSessionCookie(boolean flag)
Set a flag indicating whether or not the requested session ID for this request came in through a cookie. This is normally called by the HTTP Connector, when it parses the request headers.

Parameters:
flag - The new flag

setRequestedSessionId

public void setRequestedSessionId(String id)
Set the requested session ID for this request. This is normally called by the HTTP Connector, when it parses the request headers.

Parameters:
id - The new session id

setRequestedSessionURL

public void setRequestedSessionURL(boolean flag)
Set a flag indicating whether or not the requested session ID for this request came in through a URL. This is normally called by the HTTP Connector, when it parses the request headers.

Parameters:
flag - The new flag

setRequestedSessionSSL

public void setRequestedSessionSSL(boolean flag)
Set a flag indicating whether or not the requested session ID for this request came in through SSL. This is normally called by the HTTP Connector, when it parses the request headers.

Parameters:
flag - The new flag

getDecodedRequestURI

public String getDecodedRequestURI()
Get the decoded request URI.

Returns:
the URL decoded request URI

getDecodedRequestURIMB

@Deprecated
public MessageBytes getDecodedRequestURIMB()
Deprecated. 

Get the decoded request URI.

Returns:
the URL decoded request URI

setServletPath

@Deprecated
public void setServletPath(String path)
Deprecated. 

Set the servlet path for this Request. This will normally be called when the associated Context is mapping the Request to a particular Wrapper.

Parameters:
path - The servlet path

setUserPrincipal

public void setUserPrincipal(Principal principal)
Set the Principal who has been authenticated for this Request. This value is also used to calculate the value to be returned by the getRemoteUser() method.

Parameters:
principal - The user Principal

getAuthType

public String getAuthType()
Return the authentication type used for this Request.

Specified by:
getAuthType in interface HttpServletRequest
Returns:
one of the static members BASIC_AUTH, FORM_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH (suitable for == comparison) or the container-specific string indicating the authentication scheme, or null if the request was not authenticated.

getContextPath

public String getContextPath()
Return the portion of the request URI used to select the Context of the Request.

Specified by:
getContextPath in interface HttpServletRequest
Returns:
a String specifying the portion of the request URI that indicates the context of the request

getContextPathMB

@Deprecated
public MessageBytes getContextPathMB()
Deprecated. 

Get the context path.

Returns:
the context path

getCookies

public Cookie[] getCookies()
Return the set of Cookies received with this Request.

Specified by:
getCookies in interface HttpServletRequest
Returns:
an array of all the Cookies included with this request, or null if the request has no cookies

setCookies

@Deprecated
public void setCookies(Cookie[] cookies)
Deprecated. 

Set the set of cookies received with this Request.


getDateHeader

public long getDateHeader(String name)
Return the value of the specified date header, if any; otherwise return -1.

Specified by:
getDateHeader in interface HttpServletRequest
Parameters:
name - Name of the requested date header
Returns:
a long value representing the date specified in the header expressed as the number of milliseconds since January 1, 1970 GMT, or -1 if the named header was not included with the request
Throws:
IllegalArgumentException - if the specified header value cannot be converted to a date

getHeader

public String getHeader(String name)
Return the first value of the specified header, if any; otherwise, return null

Specified by:
getHeader in interface HttpServletRequest
Parameters:
name - Name of the requested header
Returns:
a String containing the value of the requested header, or null if the request does not have a header of that name

getHeaders

public Enumeration<String> getHeaders(String name)
Return all of the values of the specified header, if any; otherwise, return an empty enumeration.

Specified by:
getHeaders in interface HttpServletRequest
Parameters:
name - Name of the requested header
Returns:
an Enumeration containing the values of the requested header. If the request does not have any headers of that name return an empty enumeration. If the container does not allow access to header information, return null

getHeaderNames

public Enumeration<String> getHeaderNames()
Return the names of all headers received with this request.

Specified by:
getHeaderNames in interface HttpServletRequest
Returns:
an enumeration of all the header names sent with this request; if the request has no headers, an empty enumeration; if the servlet container does not allow servlets to use this method, null

getIntHeader

public int getIntHeader(String name)
Return the value of the specified header as an integer, or -1 if there is no such header for this request.

Specified by:
getIntHeader in interface HttpServletRequest
Parameters:
name - Name of the requested header
Returns:
an integer expressing the value of the request header or -1 if the request doesn't have a header of this name
Throws:
IllegalArgumentException - if the specified header value cannot be converted to an integer

getMethod

public String getMethod()
Return the HTTP request method used in this Request.

Specified by:
getMethod in interface HttpServletRequest
Returns:
a String specifying the name of the method with which this request was made

getPathInfo

public String getPathInfo()
Return the path information associated with this Request.

Specified by:
getPathInfo in interface HttpServletRequest
Returns:
a String, decoded by the web container, specifying extra path information that comes after the servlet path but before the query string in the request URL; or null if the URL does not have any extra path information

getPathInfoMB

@Deprecated
public MessageBytes getPathInfoMB()
Deprecated. 

Get the path info.

Returns:
the path info

getPathTranslated

public String getPathTranslated()
Return the extra path information for this request, translated to a real path.

Specified by:
getPathTranslated in interface HttpServletRequest
Returns:
a String specifying the real path, or null if the URL does not have any extra path information

getQueryString

public String getQueryString()
Return the query string associated with this request.

Specified by:
getQueryString in interface HttpServletRequest
Returns:
a String containing the query string or null if the URL contains no query string. The value is not decoded by the container.

getRemoteUser

public String getRemoteUser()
Return the name of the remote user that has been authenticated for this Request.

Specified by:
getRemoteUser in interface HttpServletRequest
Returns:
a String specifying the login of the user making this request, or null if the user login is not known

getRequestPathMB

public MessageBytes getRequestPathMB()
Get the request path.

Returns:
the request path

getRequestedSessionId

public String getRequestedSessionId()
Return the session identifier included in this request, if any.

Specified by:
getRequestedSessionId in interface HttpServletRequest
Returns:
a String specifying the session ID, or null if the request did not specify a session ID
See Also:
HttpServletRequest.isRequestedSessionIdValid()

getRequestURI

public String getRequestURI()
Return the request URI for this request.

Specified by:
getRequestURI in interface HttpServletRequest
Returns:
a String containing the part of the URL from the protocol name up to the query string
See Also:
HttpUtils.getRequestURL(javax.servlet.http.HttpServletRequest)

getRequestURL

public StringBuffer getRequestURL()
Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.

Because this method returns a StringBuffer, not a String, you can modify the URL easily, for example, to append query parameters.

This method is useful for creating redirect messages and for reporting errors.

Specified by:
getRequestURL in interface HttpServletRequest
Returns:
A StringBuffer object containing the reconstructed URL

getServletPath

public String getServletPath()
Return the portion of the request URI used to select the servlet that will process this request.

Specified by:
getServletPath in interface HttpServletRequest
Returns:
a String containing the name or path of the servlet being called, as specified in the request URL, decoded, or an empty string if the servlet used to process the request is matched using the "/*" pattern.

getServletPathMB

@Deprecated
public MessageBytes getServletPathMB()
Deprecated. 

Get the servlet path.

Returns:
the servlet path

getSession

public HttpSession getSession()
Return the session associated with this Request, creating one if necessary.

Specified by:
getSession in interface HttpServletRequest
Returns:
the HttpSession associated with this request
See Also:
HttpServletRequest.getSession(boolean)

getSession

public HttpSession getSession(boolean create)
Return the session associated with this Request, creating one if necessary and requested.

Specified by:
getSession in interface HttpServletRequest
Parameters:
create - Create a new session if one does not exist
Returns:
the HttpSession associated with this request or null if create is false and the request has no valid session
See Also:
HttpServletRequest.getSession()

isRequestedSessionIdFromCookie

public boolean isRequestedSessionIdFromCookie()
Return true if the session identifier included in this request came from a cookie.

Specified by:
isRequestedSessionIdFromCookie in interface HttpServletRequest
Returns:
true if the session ID came in as a cookie; otherwise, false
See Also:
HttpServletRequest.getSession(boolean)

isRequestedSessionIdFromURL

public boolean isRequestedSessionIdFromURL()
Return true if the session identifier included in this request came from the request URI.

Specified by:
isRequestedSessionIdFromURL in interface HttpServletRequest
Returns:
true if the session ID came in as part of a URL; otherwise, false
See Also:
HttpServletRequest.getSession(boolean)

isRequestedSessionIdFromUrl

@Deprecated
public boolean isRequestedSessionIdFromUrl()
Deprecated. As of Version 2.1 of the Java Servlet API, use isRequestedSessionIdFromURL() instead.

Return true if the session identifier included in this request came from the request URI.

Specified by:
isRequestedSessionIdFromUrl in interface HttpServletRequest

isRequestedSessionIdValid

public boolean isRequestedSessionIdValid()
Return true if the session identifier included in this request identifies a valid session.

Specified by:
isRequestedSessionIdValid in interface HttpServletRequest
Returns:
true if this request has an id for a valid session in the current session context; false otherwise
See Also:
HttpServletRequest.getRequestedSessionId(), HttpServletRequest.getSession(boolean), HttpSessionContext

isUserInRole

public boolean isUserInRole(String role)
Return true if the authenticated user principal possesses the specified role name.

Specified by:
isUserInRole in interface HttpServletRequest
Parameters:
role - Role name to be validated
Returns:
a boolean indicating whether the user making this request belongs to a given role; false if the user has not been authenticated

getPrincipal

public Principal getPrincipal()
Return the principal that has been authenticated for this Request.


getUserPrincipal

public Principal getUserPrincipal()
Return the principal that has been authenticated for this Request.

Specified by:
getUserPrincipal in interface HttpServletRequest
Returns:
a java.security.Principal containing the name of the user making this request; null if the user has not been authenticated

getSessionInternal

public Session getSessionInternal()
Return the session associated with this Request, creating one if necessary.


changeSessionId

public void changeSessionId(String newSessionId)
Change the ID of the session that this request is associated with. There are several things that may trigger an ID change. These include moving between nodes in a cluster and session fixation prevention during the authentication process.

Parameters:
newSessionId - The session to change the session ID for

getSessionInternal

public Session getSessionInternal(boolean create)
Return the session associated with this Request, creating one if necessary and requested.

Parameters:
create - Create a new session if one does not exist

getEvent

public CometEventImpl getEvent()
Get the event associated with the request.

Returns:
the event

isComet

public boolean isComet()
Return true if the current request is handling Comet traffic.


setComet

public void setComet(boolean comet)
Set comet state.


isParametersParsed

public boolean isParametersParsed()
return true if we have parsed parameters


getAvailable

public boolean getAvailable()
Return true if bytes are available.


checkSwallowInput

protected void checkSwallowInput()
Disable swallowing of remaining input if configured


cometClose

public void cometClose()

setCometTimeout

public void setCometTimeout(long timeout)

isRequestedSessionIdFromSSL

@Deprecated
public boolean isRequestedSessionIdFromSSL()
Deprecated. 

Not part of Servlet 3 spec but probably should be.

Returns:
true if the requested session ID was obtained from the SSL session

authenticate

public boolean authenticate(HttpServletResponse response)
                     throws IOException,
                            ServletException
Specified by:
authenticate in interface HttpServletRequest
Returns:
TODO
Throws:
IOException - If an I/O error occurs
IllegalStateException - If the response has been committed
ServletException - If the caller is responsible for handling the error and the container has NOT set the HTTP response code etc.

login

public void login(String username,
                  String password)
           throws ServletException

Specified by:
login in interface HttpServletRequest
Throws:
ServletException - If any of HttpServletRequest.getRemoteUser(), HttpServletRequest.getUserPrincipal() or HttpServletRequest.getAuthType() are non-null, if the configured authenticator does not support user name and password authentication or if the authentication fails

logout

public void logout()
            throws ServletException

Specified by:
logout in interface HttpServletRequest
Throws:
ServletException - If the logout fails

getParts

public Collection<Part> getParts()
                          throws IOException,
                                 IllegalStateException,
                                 ServletException
Return a collection of all uploaded Parts.

Specified by:
getParts in interface HttpServletRequest
Returns:
A collection of all uploaded Parts.
Throws:
IOException - if an I/O error occurs
IllegalStateException - if size limits are exceeded
ServletException - if the request is not multipart/form-data

getPart

public Part getPart(String name)
             throws IOException,
                    IllegalStateException,
                    ServletException
Gets the named Part or null if the Part does not exist. Triggers upload of all Parts.

Specified by:
getPart in interface HttpServletRequest
Returns:
The named Part or null if the Part does not exist
Throws:
IOException - if an I/O error occurs
IllegalStateException - if size limits are exceeded
ServletException - if the request is not multipart/form-data

doUpgrade

public void doUpgrade(UpgradeInbound inbound)
               throws IOException
Throws:
IOException

doGetSession

protected Session doGetSession(boolean create)

unescape

protected String unescape(String s)

parseCookies

protected void parseCookies()
Parse cookies.


parseParameters

protected void parseParameters()
Parse request parameters.


readPostBody

protected int readPostBody(byte[] body,
                           int len)
                    throws IOException
Read post body in an array.

Throws:
IOException

readChunkedPostBody

protected byte[] readChunkedPostBody()
                              throws IOException
Read chunked post body.

Throws:
IOException

parseLocales

protected void parseLocales()
Parse request locales.


parseLocalesHeader

protected void parseLocalesHeader(String value)
Parse accept-language header value.


isAlpha

protected static final boolean isAlpha(String value)

Apache Tomcat 7.0.28

Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.