Interface javax.servlet.http.HttpServletRequest
All Packages Class Hierarchy This Package Previous Next Index
Interface javax.servlet.http.HttpServletRequest
- public interface HttpServletRequest
- extends ServletRequest
An HTTP servlet request. This interface gets data from the client
to the servlet for use in the HttpServlet.service
method. It allows the HTTP-protocol specified header information to
be accessed from the service
method. This interface is
implemented by network-service developers for use within servlets.
- Version:
- 1.26, 04/16/98
-
getAuthType()
- Gets the authentication scheme of this request.
-
getCookies()
- Gets the array of cookies found in this request.
-
getDateHeader(String)
- Gets the value of the requested date header field of this
request.
-
getHeader(String)
- Gets the value of the requested header field of this request.
-
getHeaderNames()
- Gets the header names for this request.
-
getIntHeader(String)
- Gets the value of the specified integer header field of this
request.
-
getMethod()
- Gets the HTTP method (for example, GET, POST, PUT) with which
this request was made.
-
getPathInfo()
- Gets any optional extra path information following the servlet
path of this request's URI, but immediately preceding its query
string.
-
getPathTranslated()
- Gets any optional extra path information following the servlet
path of this request's URI, but immediately preceding its query
string, and translates it to a real path.
-
getQueryString()
- Gets any query string that is part of the HTTP request URI.
-
getRemoteUser()
- Gets the name of the user making this request.
-
getRequestURI()
- Gets, from the first line of the HTTP request, the part of this
request's URI that is to the left of any query string.
-
getRequestedSessionId()
- Gets the session id specified with this request.
-
getServletPath()
- Gets the part of this request's URI that refers to the servlet
being invoked.
-
getSession(boolean)
- Gets the current valid session associated with this request, if
create is false or, if necessary, creates a new session for the
request, if create is true.
-
isRequestedSessionIdFromCookie()
- Checks whether the session id specified by this request came in
as a cookie.
-
isRequestedSessionIdFromUrl()
- Checks whether the session id specified by this request came in
as part of the URL.
-
isRequestedSessionIdValid()
- Checks whether this request is associated with a session that
is valid in the current session context.
getAuthType
public abstract java.lang.String getAuthType()
- Gets the authentication scheme of this request. Same as the CGI
variable AUTH_TYPE.
- Returns:
- this request's authentication scheme, or null if none.
getCookies
public abstract javax.servlet.http.Cookie[] getCookies()
- Gets the array of cookies found in this request.
- Returns:
- the array of cookies found in this request
getDateHeader
public abstract long getDateHeader(String name)
- Gets the value of the requested date header field of this
request. If the header can't be converted to a date, the method
throws an IllegalArgumentException. The case of the header
field name is ignored.
- Parameters:
- name - the String containing the name of the requested
header field
- Returns:
- the value the requested date header field, or -1 if not
found.
getHeader
public abstract java.lang.String getHeader(String name)
- Gets the value of the requested header field of this request.
The case of the header field name is ignored.
- Parameters:
- name - the String containing the name of the requested
header field
- Returns:
- the value of the requested header field, or null if not
known.
getHeaderNames
public abstract java.util.Enumeration getHeaderNames()
- Gets the header names for this request.
- Returns:
- an enumeration of strings representing the header names
for this request. Some server implementations do not allow
headers to be accessed in this way, in which case this method
will return null.
getIntHeader
public abstract int getIntHeader(String name)
- Gets the value of the specified integer header field of this
request. The case of the header field name is ignored. If the
header can't be converted to an integer, the method throws a
NumberFormatException.
- Parameters:
- name - the String containing the name of the requested
header field
- Returns:
- the value of the requested header field, or -1 if not
found.
getMethod
public abstract java.lang.String getMethod()
- Gets the HTTP method (for example, GET, POST, PUT) with which
this request was made. Same as the CGI variable REQUEST_METHOD.
- Returns:
- the HTTP method with which this request was made
getPathInfo
public abstract java.lang.String getPathInfo()
- Gets any optional extra path information following the servlet
path of this request's URI, but immediately preceding its query
string. Same as the CGI variable PATH_INFO.
- Returns:
- the optional path information following the servlet
path, but before the query string, in this request's URI; null
if this request's URI contains no extra path information
getPathTranslated
public abstract java.lang.String getPathTranslated()
- Gets any optional extra path information following the servlet
path of this request's URI, but immediately preceding its query
string, and translates it to a real path. Similar to the CGI
variable PATH_TRANSLATED
- Returns:
- extra path information translated to a real path or null
if no extra path information is in the request's URI
getQueryString
public abstract java.lang.String getQueryString()
- Gets any query string that is part of the HTTP request URI.
Same as the CGI variable QUERY_STRING.
- Returns:
- query string that is part of this request's URI, or null
if it contains no query string
getRemoteUser
public abstract java.lang.String getRemoteUser()
- Gets the name of the user making this request. The user name is
set with HTTP authentication. Whether the user name will
continue to be sent with each subsequent communication is
browser-dependent. Same as the CGI variable REMOTE_USER.
- Returns:
- the name of the user making this request, or null if not
known.
getRequestURI
public abstract java.lang.String getRequestURI()
- Gets, from the first line of the HTTP request, the part of this
request's URI that is to the left of any query string.
For example,
First line of HTTP request |
| Return from getRequestURI
|
---|
POST /some/path.html HTTP/1.1 | | /some/path.html
|
GET http://foo.bar/a.html HTTP/1.0
| | http://foo.bar/a.html
|
HEAD /xyz?a=b HTTP/1.1 | | /xyz
|
To reconstruct a URL with a URL scheme and host, use the
method javax.servlet.http.HttpUtils.getRequestURL, which returns
a StringBuffer.
- Returns:
- this request's URI
- See Also:
- getRequestURL
getRequestedSessionId
public abstract java.lang.String getRequestedSessionId()
- Gets the session id specified with this request. This may
differ from the actual session id. For example, if the request
specified an id for an invalid session, then this will get a new
session with a new id.
- Returns:
- the session id specified by this request, or null if the
request did not specify a session id
getServletPath
public abstract java.lang.String getServletPath()
- Gets the part of this request's URI that refers to the servlet
being invoked. Analogous to the CGI variable SCRIPT_NAME.
- Returns:
- the servlet being invoked, as contained in this
request's URI
getSession
public abstract javax.servlet.http.HttpSession getSession(boolean create)
- Gets the current valid session associated with this request, if
create is false or, if necessary, creates a new session for the
request, if create is true.
Note: to ensure the session is properly maintained,
the servlet developer must call this method (at least once)
before any output is written to the response.
Additionally, application-writers need to be aware that newly
created sessions (that is, sessions for which
HttpSession.isNew
returns true) do not have any
application-specific state.
- Returns:
- the session associated with this request or null if
create was false and no valid session is associated
with this request.
isRequestedSessionIdFromCookie
public abstract boolean isRequestedSessionIdFromCookie()
- Checks whether the session id specified by this request came in
as a cookie. (The requested session may not be one returned by
the
getSession
method.)
- Returns:
- true if the session id specified by this request came in
as a cookie; false otherwise
- See Also:
- getSession
isRequestedSessionIdFromUrl
public abstract boolean isRequestedSessionIdFromUrl()
- Checks whether the session id specified by this request came in
as part of the URL. (The requested session may not be the one
returned by the
getSession
method.)
- Returns:
- true if the session id specified by the request for this
session came in as part of the URL; false otherwise
- See Also:
- getSession
isRequestedSessionIdValid
public abstract boolean isRequestedSessionIdValid()
- Checks whether this request is associated with a session that
is valid in the current session context. If it is not valid,
the requested session will never be returned from the
getSession
method.
- Returns:
- true if this request is assocated with a session that is
valid in the current session context.
- See Also:
- getRequestedSessionId, HttpSessionContext, getSession
All Packages Class Hierarchy This Package Previous Next Index