javax.servlet.ServletRequest interface
to provide request information for HTTP servlets.
The servlet container creates an HttpServletRequest
object and passes it as an argument to the servlet's service
methods (doGet, doPost, etc).
| Modifier and Type | Field and Description |
|---|---|
| public static final String | BASIC_AUTH
String identifier for Basic authentication. |
| public static final String | CLIENT_CERT_AUTH
String identifier for Client Certificate authentication. |
| public static final String | DIGEST_AUTH
String identifier for Digest authentication. |
| public static final String | FORM_AUTH
String identifier for Form authentication. |
| Modifier and Type | Method and Description |
|---|---|
| public String | 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, ornull if the request
was not authenticated.Returns the name of the authentication scheme used to protect the servlet. |
| public String | Returns: aString specifying the portion of the request
URI that indicates the context of the requestReturns the portion of the request URI that indicates the context of the request. |
| public Cookie[] | Returns: an array of all theCookies
included with this request, or null
if the request has no cookiesReturns an array containing all of the |
| public long | Returns: along 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 reqesta name)String specifying the
name of the headerReturns the value of the specified request header
as a |
| public String | |
| public Enumeration | 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,nullReturns an enumeration of all the header names this request contains. |
| public Enumeration | Returns: anEnumeration 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 nulla name)String specifying the
header nameReturns all the values of the specified request header
as an |
| public int | Returns: an integer expressing the value of the request header or -1 if the request doesn't have a header of this namea name)String specifying the name
of a request headerReturns the value of the specified request header
as an |
| public String | Returns: aString specifying the name of the method with
which this request was madeReturns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. |
| public String | Returns: aString, 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 informationReturns any extra path information associated with the URL the client sent when it made this request. |
| public String | Returns: aString specifying the real path, or
null if the URL does not have any extra path informationReturns any extra path information after the servlet name but before the query string, and translates it to a real path. |
| public String | Returns: aString containing the query string or
null if the URL contains no query string. The value is not
decoded by the container.Returns the query string that is contained in the request URL after the path. |
| public String | Returns: aString specifying the login of the user making
this request, or null if the user login is not knownReturns the login of the user making this request, if the user has been
authenticated, or |
| public String | Returns: aString specifying the session ID, or
null if the request did not specify a session IDReturns the session ID specified by the client. |
| public String | Returns: aString containing the part of the URL
from the protocol name up to the query stringReturns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. |
| public StringBuffer | Returns: aStringBuffer object containing the reconstructed URLReconstructs the URL the client used to make the request. |
| public String | Returns: aString 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.Returns the part of this request's URL that calls the servlet. |
| public HttpSession | Returns: theHttpSession associated with this request or
null if create is false and the
request has no valid sessiontrue to create a new session for this request
if necessary; false to return null if there's
no current sessionReturns the current |
| public HttpSession | Returns: theHttpSession associated with this requestReturns the current session associated with this request, or if the request does not have a session, creates one. |
| public Principal | Returns: ajava.security.Principal containing the name
of the user making this request; null if the user has
not been authenticatedReturns a |
| public boolean | Returns: true if the session ID came in as a cookie;
otherwise, falseChecks whether the requested session ID came in as a cookie. |
| public boolean | Returns: true if the session ID came in as part of a URL;
otherwise, falseChecks whether the requested session ID came in as part of the request URL. |
| public boolean | isRequestedSessionIdFromUrl()
Deprecated
As of Version 2.1 of the Java Servlet API, use
isRequestedSessionIdFromURL instead.
|
| public boolean | Returns: true if this request has an id for a valid session
in the current session context; false otherwiseChecks whether the requested session ID is still valid. |
| public boolean | Returns: aboolean indicating whether the user
making this request belongs to a given role; false
if the user has not been authenticateda role)String specifying the name of the roleReturns a boolean indicating whether the authenticated user is included in the specified logical "role". |
| BASIC_AUTH | back to summary |
|---|---|
| public static final String BASIC_AUTH String identifier for Basic authentication. Value "BASIC" | |
| CLIENT_CERT_AUTH | back to summary |
|---|---|
| public static final String CLIENT_CERT_AUTH String identifier for Client Certificate authentication. Value "CLIENT_CERT" | |
| DIGEST_AUTH | back to summary |
|---|---|
| public static final String DIGEST_AUTH String identifier for Digest authentication. Value "DIGEST" | |
| FORM_AUTH | back to summary |
|---|---|
| public static final String FORM_AUTH String identifier for Form authentication. Value "FORM" | |
| getAuthType | back to summary |
|---|---|
| public String getAuthType() Returns the name of the authentication scheme used to protect
the servlet. All servlet containers support basic, form and client
certificate authentication, and may additionally support digest
authentication.
If the servlet is not authenticated Same as the value of the CGI variable AUTH_TYPE.
| |
| getContextPath | back to summary |
|---|---|
| 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 servlets in the default (root) context, this method returns "". The container does not decode this string.
| |
| getCookies | back to summary |
|---|---|
| public Cookie[] getCookies() Returns an array containing all of the
| |
| getDateHeader | back to summary |
|---|---|
| public long getDateHeader(String name) Returns the value of the specified request header
as a The date is returned as the number of milliseconds since January 1, 1970 GMT. The header name is case insensitive. If the request did not have a header of the
specified name, this method returns -1. If the header
can't be converted to a date, the method throws
an
| |
| getHeader | back to summary |
|---|---|
| public String getHeader(String name) Returns the value of the specified request header
as a | |
| getHeaderNames | back to summary |
|---|---|
| public Enumeration Returns an enumeration of all the header names this request contains. If the request has no headers, this method returns an empty enumeration. Some servlet containers do not allow servlets to access headers
using this method, in which case this method returns
| |
| getHeaders | back to summary |
|---|---|
| public Enumeration Returns all the values of the specified request header
as an Some headers, such as If the request did not include any headers
of the specified name, this method returns an empty
| |
| getIntHeader | back to summary |
|---|---|
| public int getIntHeader(String name) Returns the value of the specified request header
as an The header name is case insensitive.
| |
| getMethod | back to summary |
|---|---|
| public String getMethod() Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. Same as the value of the CGI variable REQUEST_METHOD.
| |
| getPathInfo | back to summary |
|---|---|
| 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 servlet path but precedes the query string and will start with a "/" character. This method returns Same as the value of the CGI variable PATH_INFO.
| |
| getPathTranslated | back to summary |
|---|---|
| public String getPathTranslated() Returns any extra path information after the servlet name but before the query string, and translates it to a real path. Same as the value of the CGI variable PATH_TRANSLATED. If the URL does not have any extra path information, this method
returns
| |
| getQueryString | back to summary |
|---|---|
| public String getQueryString() Returns the query string that is contained in the request URL after
the path. This method returns
| |
| getRemoteUser | back to summary |
|---|---|
| public String getRemoteUser() Returns the login of the user making this request, if the user has been
authenticated, or
| |
| getRequestedSessionId | back to summary |
|---|---|
| public String getRequestedSessionId() Returns the session ID specified by the client. This may not be the
same as the ID of the current valid session for this request.
If the client did not specify a session ID, this method returns
| |
| getRequestURI | back to summary | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| public String getRequestURI() Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. The web container does not decode this String. For example:
To reconstruct an URL with a scheme and host, use
| ||||||||||||
| getRequestURL | back to summary |
|---|---|
| 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 This method is useful for creating redirect messages and for reporting errors.
| |
| getServletPath | back to summary |
|---|---|
| public String getServletPath() Returns the part of this request's URL that calls the servlet. This path starts with a "/" character and includes either the servlet name or a path to the servlet, but does not include any extra path information or a query string. Same as the value of the CGI variable SCRIPT_NAME. This method will return an empty string ("") if the servlet used to process this request was matched using the "/*" pattern.
| |
| getSession | back to summary |
|---|---|
| public HttpSession getSession(boolean create) Returns the current If To make sure the session is properly maintained, you must call this method before the response is committed. If the container is using cookies to maintain session integrity and is asked to create a new session when the response is committed, an IllegalStateException is thrown.
| |
| getSession | back to summary |
|---|---|
| public HttpSession getSession() Returns the current session associated with this request, or if the request does not have a session, creates one.
| |
| getUserPrincipal | back to summary |
|---|---|
| public Principal getUserPrincipal() Returns a
| |
| isRequestedSessionIdFromCookie | back to summary |
|---|---|
| public boolean isRequestedSessionIdFromCookie() Checks whether the requested session ID came in as a cookie.
| |
| isRequestedSessionIdFromURL | back to summary |
|---|---|
| public boolean isRequestedSessionIdFromURL() Checks whether the requested session ID came in as part of the request URL.
| |
| isRequestedSessionIdFromUrl | back to summary |
|---|---|
| public boolean isRequestedSessionIdFromUrl()
Deprecated As of Version 2.1 of the Java Servlet API, use
| |
| isRequestedSessionIdValid | back to summary |
|---|---|
| public boolean isRequestedSessionIdValid() Checks whether the requested session ID is still valid.
| |
| isUserInRole | back to summary |
|---|---|
| public boolean isUserInRole(String role) Returns a boolean indicating whether the authenticated user is included
in the specified logical "role". Roles and role membership can be
defined using deployment descriptors. If the user has not been
authenticated, the method returns
| |