org.glassfish.grizzly.http.server
Class Request

java.lang.Object
  extended by org.glassfish.grizzly.http.server.Request

public class Request
extends Object

Wrapper object for the Coyote request.

Version:
$Revision: 1.2 $ $Date: 2007/03/14 02:15:42 $
Author:
Remy Maucherat, Craig R. McClanahan

Field Summary
protected  List<AfterServiceListener> afterServicesList
           
protected static int CACHED_POST_LEN
          Post data buffer.
protected  Cookie[] cookies
          The set of cookies associated with this Request.
protected  boolean cookiesParsed
          Cookies parsed flag.
protected  FilterChainContext ctx
           
protected static Locale defaultLocale
          The default Locale if none are specified.
protected  Object dispatcherType
          The current dispatcher type.
protected  HttpServerFilter httpServerFilter
           
protected  InputBuffer inputBuffer
          The associated input buffer.
protected  ArrayList<Locale> locales
          The preferred Locales associated with this Request.
protected  boolean localesParsed
          Parse locales.
protected  ParameterMap parameterMap
          Hash map used in the getParametersMap method.
protected  Parameters parameters
           
protected  byte[] postData
           
protected  Cookies rawCookies
           
protected  HttpRequestPacket request
          HTTP Request Packet
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 requestedSessionURL
          Was the requested session ID received in a URL?
protected  boolean requestParametersParsed
          Request parameters parsed flag.
protected  Response response
          The response with which this request is associated.
protected  boolean secure
          Secure flag.
static String SEND_FILE_ATTR
           The value of this request attribute, as set by the developer must be a File that exists, is not a directory, and is readable.
static String SEND_FILE_ENABLED_ATTR
          Request attribute will be associated with a boolean value indicating whether or not it's possible to transfer a File using sendfile.
static String SEND_FILE_START_OFFSET_ATTR
           The value of this request attribute signifies the starting offset of the file transfer.
static String SEND_FILE_WRITE_LEN_ATTR
           The value of this request attribute signifies the total number of bytes to transfer.
protected  boolean sessionParsed
          Session parsed flag.
protected  Subject subject
          The Subject associated with the current AccessControllerContext
protected  Principal userPrincipal
          User principal.
protected  boolean usingInputStream
          Using stream flag.
protected  boolean usingReader
          Using writer flag.
 
Constructor Summary
protected Request()
           
 
Method Summary
 void addAfterServiceListener(AfterServiceListener listener)
          Add the listener, which will be notified, once Request processing will be finished.
 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)
          Add a parameter name and corresponding set of values to this Request.
static StringBuffer appendRequestURL(Request request, StringBuffer buffer)
          Appends the reconstructed URL the client used to make the request.
static StringBuilder appendRequestURL(Request request, StringBuilder buffer)
          Appends the reconstructed URL the client used to make the request.
 boolean asyncInput()
           
 void clearCookies()
          Clear the collection of Cookies associated with this Request.
 void clearHeaders()
          Clear the collection of Headers associated with this Request.
 void clearLocales()
          Clear the collection of Locales associated with this Request.
 void clearParameters()
          Clear the collection of parameters associated with this Request.
protected  void configureSessionCookie(Cookie cookie)
          Configures the given JSESSIONID cookie.
static Request create()
           
 NIOInputStream createInputStream()
          Create and return a NIOInputStream to read the content associated with this Request.
static
<E> Note<E>
createNote(String name)
          Create a named Note associated with this Request.
 int decrementDispatchDepth()
          Decrement the depth of application dispatch
protected  Session doGetSession(boolean create)
           
 Object getAttribute(String name)
          Return the specified request attribute if it exists; otherwise, return null.
 Set<String> getAttributeNames()
          Return the names of all request attributes for this Request, or an empty Set if there are none.
 String getAuthorization()
          Return the authorization credentials sent with this request.
 String getAuthType()
          Return the authentication type used for this Request.
 String getCharacterEncoding()
          Return the character encoding for this Request.
 int getContentLength()
          Return the content length for this Request.
 long getContentLengthLong()
          Return the content length for this Request represented by Java long type.
 String getContentType()
          Return the content type for this Request.
 FilterChainContext getContext()
           
 String getContextPath()
          Returns the portion of the request URI that indicates the context of the request.
 Cookie[] getCookies()
          Return the set of Cookies received with this Request.
 long getDateHeader(Header header)
          Return the value of the specified date header, if any; otherwise return -1.
 long getDateHeader(String name)
          Return the value of the specified date header, if any; otherwise return -1.
 String getDecodedRequestURI()
          Get the decoded request URI.
 String getHeader(Header header)
          Return the first value of the specified header, if any; otherwise, return null
 String getHeader(String name)
          Return the first value of the specified header, if any; otherwise, return null
 Iterable<String> getHeaderNames()
          Return the names of all headers received with this request.
 Iterable<String> getHeaders(Header header)
          Return all of the values of the specified header, if any; otherwise, return an empty enumeration.
 Iterable<String> getHeaders(String name)
          Return all of the values of the specified header, if any; otherwise, return an empty enumeration.
 String getHttpHandlerPath()
          Returns the part of this request's URL that calls the HttpHandler.
 InputBuffer getInputBuffer()
           
 InputStream getInputStream()
           Return the InputStream for this Request.
 int getIntHeader(Header header)
          Return the value of the specified header as an integer, or -1 if there is no such header 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 getJrouteId()
          Gets the jroute id of this request, which may have been sent as a separate JROUTE cookie or appended to the session identifier encoded in the URI (if cookies have been disabled).
 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.
 List<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.
static int getMaxDispatchDepth()
           
 Method getMethod()
          Return the HTTP request method used in this Request.
 NIOInputStream getNIOInputStream()
           Return the NIOInputStream for this Request.
 NIOReader getNIOReader()
           Returns the NIOReader associated with this Request.
<E> E
getNote(Note<E> note)
          Return the Note value associated with this Request, or null if no such binding exists.
 Set<String> getNoteNames()
          Return a Set containing the String names of all note bindings that exist for this request.
 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.
 Set<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.
 String getPathInfo()
          Returns any extra path information associated with the URL the client sent when it made this request.
 Buffer getPostBody(int len)
          Gets the POST body of this request.
 Protocol getProtocol()
          Return the protocol and version used to make this Request.
 String getQueryString()
          Return the query string associated with this request.
protected  Cookies getRawCookies()
          TODO DOCS
 Reader getReader()
           Returns the Reader associated with this Request.
 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.
 HttpRequestPacket getRequest()
          Get the Coyote request.
 String getRequestedSessionId()
          Return the session identifier included in this request, if any.
 String getRequestURI()
          Return the request URI for this request.
 StringBuilder 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.
 Session getSession()
          Return the session associated with this Request, creating one if necessary.
 Session getSession(boolean create)
          Return the session associated with this Request, creating one if necessary and requested.
 Principal getUserPrincipal()
          Return the principal that has been authenticated for this Request.
 int incrementDispatchDepth()
          Increment the depth of application dispatch
 void initialize(Response response, HttpRequestPacket request, FilterChainContext ctx, HttpServerFilter httpServerFilter)
           
 void initiateAsyncronousDataReceiving()
          Initiates asynchronous data receiving.
 boolean isMaxDispatchDepthReached()
          Check if the application dispatching has reached the maximum
 boolean isRequestedSessionIdFromCookie()
          Return true if the session identifier included in this request came from a cookie.
 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?
 MappingData obtainMappingData()
           
protected  void onAfterService()
           
protected  void parseCookies()
          Parse cookies.
protected  void parseLocales()
          Parse request locales.
protected  void parseLocalesHeader(String value)
          Parse accept-language header value.
protected  void parseRequestParameters()
          Parse request parameters.
protected  void parseSessionId()
          Parse session id in URL.
protected  void recycle()
          Release all object references, and initialize instance variables, in preparation for reuse of this object.
 void removeAfterServiceListener(AfterServiceListener listener)
          Remove the "after-service" listener, which was previously added by addAfterServiceListener(org.glassfish.grizzly.http.server.AfterServiceListener).
 void removeAttribute(String name)
          Remove the specified request attribute if it exists.
<E> E
removeNote(Note<E> note)
          Remove the Note value associated with this request.
 boolean requiresAcknowledgement()
           
 void setAttribute(String name, Object value)
          Set the specified request attribute to the specified value.
 void setCharacterEncoding(String encoding)
          Overrides the name of the character encoding used in the body of this request.
protected  void setContextPath(String contextPath)
           
 void setCookies(Cookie[] cookies)
          Set the set of cookies received with this Request.
protected  void setHttpHandlerPath(String httpHandlerPath)
           
static void setMaxDispatchDepth(int depth)
          Static setter method for the maximum dispatch depth
 void setMethod(String method)
          Sets the HTTP request method used in this Request.
<E> void
setNote(Note<E> note, E value)
          Bind the Note value to this Request, replacing any existing binding for this name.
protected  void setPathInfo(String pathInfo)
           
 void setQueryString(String queryString)
          Sets the query string 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 setRequestedSessionURL(boolean flag)
          Set a flag indicating whether or not the requested session ID for this request came in through a URL.
 void setRequestParameters(Parameters parameters)
          This method may be used if some other entity processed request parameters and wishes to expose them via the request.
 void setRequestURI(String uri)
          Sets the request URI for this request.
 void setServerName(String name)
          Set the name of the server (virtual host) to process this request.
 void setServerPort(int port)
          Set the port number of the server to process this request.
 void setUserPrincipal(Principal principal)
          Set the Principal who has been authenticated for this Request.
protected  void skipPostBody(int len)
          Skips the POST body of this request.
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

SEND_FILE_ENABLED_ATTR

public static final String SEND_FILE_ENABLED_ATTR
Request attribute will be associated with a boolean value indicating whether or not it's possible to transfer a File using sendfile.

Since:
2.2
See Also:
Constant Field Values

SEND_FILE_ATTR

public static final String SEND_FILE_ATTR

The value of this request attribute, as set by the developer must be a File that exists, is not a directory, and is readable. This File will be transferred using sendfile if SEND_FILE_ENABLED_ATTR is true. If sendfile support isn't enabled, an IllegalStateException will be raised at runtime. The HttpHandler using this functionality should refrain from writing content via the response.

Note that once this attribute is set, the sendfile process will begin.

Since:
2.2
See Also:
Constant Field Values

SEND_FILE_START_OFFSET_ATTR

public static final String SEND_FILE_START_OFFSET_ATTR

The value of this request attribute signifies the starting offset of the file transfer. If not specified, an offset of zero will be assumed. The type of the value must be Long.

NOTE: In order for this attribute to take effect, it must be set before the SEND_FILE_ATTR is set.

Since:
2.2
See Also:
Constant Field Values

SEND_FILE_WRITE_LEN_ATTR

public static final String SEND_FILE_WRITE_LEN_ATTR

The value of this request attribute signifies the total number of bytes to transfer. If not specified, the entire file will be transferred. The type of the value must be Long

NOTE: In order for this attribute to take effect, it must be set before the SEND_FILE_ATTR is set.

Since:
2.2
See Also:
Constant Field Values

request

protected HttpRequestPacket request
HTTP Request Packet


ctx

protected FilterChainContext ctx

httpServerFilter

protected HttpServerFilter httpServerFilter

afterServicesList

protected final List<AfterServiceListener> afterServicesList

cookies

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


rawCookies

protected Cookies rawCookies

defaultLocale

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


locales

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


dispatcherType

protected Object dispatcherType
The current dispatcher type.


inputBuffer

protected final InputBuffer inputBuffer
The associated input buffer.


usingInputStream

protected boolean usingInputStream
Using stream flag.


usingReader

protected boolean usingReader
Using writer flag.


userPrincipal

protected Principal userPrincipal
User principal.


sessionParsed

protected boolean sessionParsed
Session parsed flag.


requestParametersParsed

protected boolean requestParametersParsed
Request parameters parsed flag.


cookiesParsed

protected boolean cookiesParsed
Cookies parsed flag.


secure

protected boolean secure
Secure flag.


subject

protected Subject subject
The Subject associated with the current AccessControllerContext


CACHED_POST_LEN

protected static final int CACHED_POST_LEN
Post data buffer.

See Also:
Constant Field Values

postData

protected byte[] postData

parameterMap

protected final ParameterMap parameterMap
Hash map used in the getParametersMap method.


parameters

protected final Parameters parameters

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?


localesParsed

protected boolean localesParsed
Parse locales.


response

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

Constructor Detail

Request

protected Request()
Method Detail

create

public static Request create()

obtainMappingData

public final MappingData obtainMappingData()

initialize

public void initialize(Response response,
                       HttpRequestPacket request,
                       FilterChainContext ctx,
                       HttpServerFilter httpServerFilter)

getRequest

public HttpRequestPacket getRequest()
Get the Coyote request.


getResponse

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


addAfterServiceListener

public void addAfterServiceListener(AfterServiceListener listener)
Add the listener, which will be notified, once Request processing will be finished.

Parameters:
listener - the listener, which will be notified, once Request processing will be finished.

removeAfterServiceListener

public void removeAfterServiceListener(AfterServiceListener listener)
Remove the "after-service" listener, which was previously added by addAfterServiceListener(org.glassfish.grizzly.http.server.AfterServiceListener).

Parameters:
listener - the "after-service" listener, which was previously added by addAfterServiceListener(org.glassfish.grizzly.http.server.AfterServiceListener).

onAfterService

protected void onAfterService()

recycle

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


getAuthorization

public String getAuthorization()
Return the authorization credentials sent with this request.


createInputStream

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

Throws:
IOException - if an input/output error occurs

createNote

public static <E> Note<E> createNote(String name)
Create a named Note associated with this Request.

Type Parameters:
E - the Note type.
Parameters:
name - the Note name.
Returns:
the Note.

getNote

public <E> E getNote(Note<E> note)
Return the Note value associated with this Request, or null if no such binding exists. Use createNote(java.lang.String) to create a new Note.

Parameters:
note - Note value to be returned

getNoteNames

public Set<String> getNoteNames()
Return a Set containing the String names of all note bindings that exist for this request. Use createNote(java.lang.String) to create a new Note.

Returns:
a Set containing the String names of all note bindings that exist for this request.

removeNote

public <E> E removeNote(Note<E> note)
Remove the Note value associated with this request. Use createNote(java.lang.String) to create a new Note.

Parameters:
note - Note value to be removed

setNote

public <E> void setNote(Note<E> note,
                        E value)
Bind the Note value to this Request, replacing any existing binding for this name. Use createNote(java.lang.String) to create a new Note.

Parameters:
note - Note to which the object should be bound
value - the Note value be bound to the specified Note.

setServerName

public void setServerName(String name)
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

getContextPath

public String getContextPath()
Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For HttpHandlers in the default (root) context, this method returns "". The container does not decode this string.

Returns:
a String specifying the portion of the request URI that indicates the context of the request

setContextPath

protected void setContextPath(String contextPath)

getHttpHandlerPath

public String getHttpHandlerPath()
Returns the part of this request's URL that calls the HttpHandler. This includes either the HttpHandler name or a path to the HttpHandler, but does not include any extra path information or a query string.

Returns:
a String containing the name or path of the HttpHandler being called, as specified in the request URL

setHttpHandlerPath

protected void setHttpHandlerPath(String httpHandlerPath)

getPathInfo

public String getPathInfo()
Returns any extra path information associated with the URL the client sent when it made this request. The extra path information follows the HttpHandler path but precedes the query string. This method returns null if there was no extra path information.

Returns:
a String specifying extra path information that comes after the HttpHandler path but before the query string in the request URL; or null if the URL does not have any extra path information

setPathInfo

protected void setPathInfo(String pathInfo)

getAttribute

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

Parameters:
name - Name of the request attribute to return

getAttributeNames

public Set<String> getAttributeNames()
Return the names of all request attributes for this Request, or an empty Set if there are none.


getCharacterEncoding

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


getContentLength

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


getContentLengthLong

public long getContentLengthLong()
Return the content length for this Request represented by Java long type.


getContentType

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


getInputStream

public InputStream getInputStream()

Return the InputStream for this Request. This stream will block when reading content.

Returns:
the InputStream for this Request.
Throws:
IllegalStateException - if getReader() or getNIOReader() has already been called for this request.
Since:
2.2
See Also:
getNIOInputStream()

getNIOInputStream

public NIOInputStream getNIOInputStream()

Return the NIOInputStream for this Request. This stream will not block when reading content.

NOTE: For now, in order to use non-blocking functionality, this method must be invoked before the HttpHandler.service(Request, Response) method returns. We hope to have this addressed in the next release.

Returns:
the NIOInputStream for this Request.
Throws:
IllegalStateException - if getReader() or getNIOReader() has already been called for this request.

asyncInput

public boolean asyncInput()
Returns:
true if the current input source is operating in non-blocking mode. In other words getNIOInputStream() or getNIOReader() were invoked.

requiresAcknowledgement

public boolean requiresAcknowledgement()
Returns:
true if this request requires acknowledgment.

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.


getLocales

public List<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.


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.

Parameters:
name - Name of the desired request parameter

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.

Returns:
A Map containing parameter names as keys and parameter values as map values.

getParameterNames

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


getParameterValues

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

Parameters:
name - Name of the desired request parameter

getProtocol

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


getReader

public Reader getReader()

Returns the Reader associated with this Request. This Reader will block while reading content.

Returns:
the Reader associated with this Request.
Throws:
IllegalStateException - if getInputStream() or getNIOInputStream() has already been called for this request.
Since:
2.2

getNIOReader

public NIOReader getNIOReader()

Returns the NIOReader associated with this Request. This NIOReader will not block while reading content.

Throws:
IllegalStateException - if getInputStream() or getNIOInputStream() has already been called for this request.

getRemoteAddr

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


getRemoteHost

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


getRemotePort

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


getLocalName

public String getLocalName()
Returns the host name of the Internet Protocol (IP) interface 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.


getLocalPort

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


getScheme

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


getServerName

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


getServerPort

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


isSecure

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


removeAttribute

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

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.

Parameters:
name - Name of the request attribute to set
value - The associated value

setCharacterEncoding

public void setCharacterEncoding(String encoding)
                          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(). Otherwise, it has no effect.

Parameters:
encoding - String containing the name of the character encoding.
Throws:
UnsupportedEncodingException - if this ServletRequest is still in a state where a character encoding may be set, but the specified encoding is invalid
Since:
Servlet 2.3

setMaxDispatchDepth

public static void setMaxDispatchDepth(int depth)
Static setter method for the maximum dispatch depth


getMaxDispatchDepth

public static int getMaxDispatchDepth()

incrementDispatchDepth

public int incrementDispatchDepth()
Increment the depth of application dispatch


decrementDispatchDepth

public int decrementDispatchDepth()
Decrement the depth of application dispatch


isMaxDispatchDepthReached

public boolean isMaxDispatchDepthReached()
Check if the application dispatching has reached the maximum


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

public void addParameter(String name,
                         String[] values)
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

public void clearHeaders()
Clear the collection of Headers associated with this Request.


clearLocales

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


clearParameters

public void clearParameters()
Clear the collection of parameters associated with this Request.


getDecodedRequestURI

public String getDecodedRequestURI()
                            throws CharConversionException
Get the decoded request URI.

Returns:
the URL decoded request URI
Throws:
CharConversionException

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.


getCookies

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


setCookies

public void setCookies(Cookie[] cookies)
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.

Parameters:
name - Name of the requested date header
Throws:
IllegalArgumentException - if the specified header value cannot be converted to a date

getDateHeader

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

Parameters:
header - the requested date Header
Throws:
IllegalArgumentException - if the specified header value cannot be converted to a date
Since:
2.1.2

getHeader

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

Parameters:
name - Name of the requested header

getHeader

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

Parameters:
header - the requested Header
Since:
2.1.2

getHeaders

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

Parameters:
name - Name of the requested header

getHeaders

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

Parameters:
header - the requested Header
Since:
2.1.2

getHeaderNames

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


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.

Parameters:
name - Name of the requested header
Throws:
IllegalArgumentException - if the specified header value cannot be converted to an integer

getIntHeader

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

Parameters:
header - the requested Header
Throws:
IllegalArgumentException - if the specified header value cannot be converted to an integer
Since:
2.1.2

getMethod

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


setMethod

public void setMethod(String method)
Sets the HTTP request method used in this Request.

Parameters:
method - the HTTP request method used in this Request.

getQueryString

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


setQueryString

public void setQueryString(String queryString)
Sets the query string associated with this request.

Parameters:
queryString - the query string associated with this request.

getRemoteUser

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


getRequestedSessionId

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


getRequestURI

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


setRequestURI

public void setRequestURI(String uri)
Sets the request URI for this request.

Parameters:
uri - the request URI for this request.

getRequestURL

public StringBuilder 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 StringBuilder, 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.

Returns:
A StringBuffer object containing the reconstructed URL

appendRequestURL

public static StringBuilder appendRequestURL(Request request,
                                             StringBuilder buffer)
Appends the reconstructed URL the client used to make the request. The appended URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.

Because this method returns a StringBuilder, 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.

Returns:
A StringBuilder object containing the appended reconstructed URL

appendRequestURL

public static StringBuffer appendRequestURL(Request request,
                                            StringBuffer buffer)
Appends the reconstructed URL the client used to make the request. The appended 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.

Returns:
A StringBuffer object containing the appended reconstructed URL

getUserPrincipal

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


getContext

public FilterChainContext getContext()

unescape

protected String unescape(String s)

parseCookies

protected void parseCookies()
Parse cookies.


getInputBuffer

public InputBuffer getInputBuffer()
Returns:
the InputBuffer associated with this request, which is the source for getInputStream(), getReader(), getNIOInputStream(), and getNIOReader()

setRequestParameters

public void setRequestParameters(Parameters parameters)
This method may be used if some other entity processed request parameters and wishes to expose them via the request. When this method is called, it will mark the internal request parameter state as having been processed.

Parameters:
parameters - the parameters to expose via this request.
Since:
2.2

getRawCookies

protected Cookies getRawCookies()
TODO DOCS


parseRequestParameters

protected void parseRequestParameters()
Parse request parameters.


getPostBody

public Buffer getPostBody(int len)
                   throws IOException
Gets the POST body of this request.

Returns:
The POST body of this request
Throws:
IOException

skipPostBody

protected void skipPostBody(int len)
                     throws IOException
Skips the POST body of this request.

Parameters:
len - how much of the POST body to skip.
Throws:
IOException

parseLocales

protected void parseLocales()
Parse request locales.


parseLocalesHeader

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


getJrouteId

public String getJrouteId()
Gets the jroute id of this request, which may have been sent as a separate JROUTE cookie or appended to the session identifier encoded in the URI (if cookies have been disabled).

Returns:
The jroute id of this request, or null if this request does not carry any jroute id

getSession

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


getSession

public Session getSession(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

doGetSession

protected Session doGetSession(boolean create)

isRequestedSessionIdFromCookie

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


isRequestedSessionIdFromURL

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


isRequestedSessionIdValid

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


configureSessionCookie

protected void configureSessionCookie(Cookie cookie)
Configures the given JSESSIONID cookie.

Parameters:
cookie - The JSESSIONID cookie to be configured

parseSessionId

protected void parseSessionId()
Parse session id in URL.


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

initiateAsyncronousDataReceiving

public void initiateAsyncronousDataReceiving()
Initiates asynchronous data receiving. This is service method, usually users don't have to call it explicitly.



Copyright © 2012 Oracle Corporation. All Rights Reserved.