All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface javax.servlet.http.HttpServletRequest

public interface HttpServletRequest
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.


Method Index

 o getAuthType()
Gets the authentication scheme of this request.
 o getCookies()
Gets the array of cookies found in this request.
 o getDateHeader(String)
Gets the value of the requested date header field of this request.
 o getHeader(String)
Gets the value of the requested header field of this request.
 o getHeaderNames()
Gets the header names for this request.
 o getIntHeader(String)
Gets the value of the specified integer header field of this request.
 o getMethod()
Gets the HTTP method (for example, GET, POST, PUT) with which this request was made.
 o getPathInfo()
Gets any optional extra path information following the servlet path of this request's URI, but immediately preceding its query string.
 o 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.
 o getQueryString()
Gets any query string that is part of the HTTP request URI.
 o getRemoteUser()
Gets the name of the user making this request.
 o getRequestedSessionId()
Gets the session id specified with this request.
 o 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.
 o getServletPath()
Gets the part of this request's URI that refers to the servlet being invoked.
 o getSession()
Gets the current valid session associated with this request, if create is false or, if necessary, creates a new session for the request.
 o 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.
 o isRequestedSessionIdFromCookie()
Checks whether the session id specified by this request came in as a cookie.
 o isRequestedSessionIdFromURL()
Checks whether the session id specified by this request came in as part of the URL.
 o isRequestedSessionIdFromUrl()
Checks whether the session id specified by this request came in as part of the URL. Deprecated.
 o isRequestedSessionIdValid()
Checks whether this request is associated with a session that is valid in the current session context.

Methods

 o getAuthType
 public abstract 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.
 o getCookies
 public abstract Cookie[] getCookies()
Gets the array of cookies found in this request.

Returns:
the array of cookies found in this request
 o 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.
 o getHeader
 public abstract 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.
 o getHeaderNames
 public abstract 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.
 o 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.
 o getMethod
 public abstract 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
 o getPathInfo
 public abstract 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
 o getPathTranslated
 public abstract 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. Same as 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
 o getQueryString
 public abstract 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
 o getRemoteUser
 public abstract 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.
 o getRequestedSessionId
 public abstract 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
See Also:
isRequestedSessionIdValid
 o getRequestURI
 public abstract 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
 o getServletPath
 public abstract 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
 o getSession
 public abstract 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.
 o getSession
 public abstract HttpSession getSession()
Gets the current valid session associated with this request, if create is false or, if necessary, creates a new session for the request.

 o 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
 o 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
 o 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
 o isRequestedSessionIdFromUrl
 public abstract boolean isRequestedSessionIdFromUrl()
Note: isRequestedSessionIdFromUrl() is deprecated. use isRequestSessionIdFromURL() instead

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

All Packages  Class Hierarchy  This Package  Previous  Next  Index