public class XPFHttpServletRequest extends Object
| Constructor and Description |
|---|
XPFHttpServletRequest(@NonNull XPFEntitySupplier<Map<String,Object>> attributes,
String characterEncoding,
int contentLength,
long contentLengthLong,
String contentType,
@NonNull XPFEntitySupplier<Map<String,List<String>>> parameters,
String protocol,
String scheme,
String serverName,
int serverPort,
String remoteAddr,
String remoteHost,
int remotePort,
XPFEntitySupplier<Locale> locale,
XPFEntitySupplier<Enumeration<Locale>> locales,
boolean secure,
String localName,
String localAddr,
int localPort,
String authType,
@NonNull String contextPath,
@NonNull XPFEntitySupplier<List<XPFHttpCookie>> cookies,
@NonNull Map<String,List<String>> headers,
@NonNull String method,
String pathInfo,
XPFEntitySupplier<String> pathTranslated,
String queryString,
XPFEntitySupplier<String> remoteUser,
String requestedSessionId,
@NonNull String requestURI,
@NonNull XPFEntitySupplier<StringBuffer> requestURL,
@NonNull String servletPath,
XPFEntitySupplier<XPFHttpSession> session,
XPFEntitySupplier<String> userPrincipal,
XPFEntitySupplier<Boolean> requestedSessionIdFromCookie,
XPFEntitySupplier<Boolean> requestedSessionIdFromURL,
XPFEntitySupplier<Boolean> requestedSessionIdValid) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
canEqual(Object other) |
boolean |
equals(Object o) |
Object |
getAttribute(String name)
Returns the value of the named attribute as an
Object,
or null if no attribute of the given name exists. |
Enumeration<String> |
getAttributeNames()
Returns an
Enumeration containing the
names of the attributes available to this request. |
Map<String,Object> |
getAttributes()
Returns a map of attributes associated with this request.
|
String |
getAuthType()
Returns the name of the authentication scheme used to protect
the servlet.
|
String |
getCharacterEncoding()
Returns the name of the character encoding used in the body of this
request.
|
int |
getContentLength()
Returns the length, in bytes, of the request body and made available by
the input stream, or -1 if the length is not known ir is greater than
Integer.MAX_VALUE.
|
long |
getContentLengthLong()
Returns the length, in bytes, of the request body and made available by
the input stream, or -1 if the length is not known.
|
String |
getContentType()
Returns the MIME type of the body of the request, or
null if the type is not known. |
@NonNull String |
getContextPath()
Returns the portion of the request URI that indicates the context
of the request.
|
List<XPFHttpCookie> |
getCookies()
Returns a list containing all of the
Cookie
objects the client sent with this request. |
long |
getDateHeader(String name)
Returns the value of the specified request header
as a
long value that represents a
Date object. |
String |
getHeader(String name)
Returns the value of the specified request header
as a
String. |
Enumeration<String> |
getHeaderNames()
Returns an enumeration of all the header names
this request contains.
|
@NonNull Map<String,List<String>> |
getHeaders()
Returns a map of all the headers that were sent with this request.
|
Enumeration<String> |
getHeaders(String name)
Returns all the values of the specified request header
as an
Enumeration of String objects. |
int |
getIntHeader(String name)
Returns the value of the specified request header
as an
int. |
String |
getLocalAddr()
Returns the Internet Protocol (IP) address of the interface on
which the request was received.
|
Locale |
getLocale()
Returns the preferred
Locale that the client will
accept content in, based on the Accept-Language header. |
Enumeration<Locale> |
getLocales()
Returns an
Enumeration of Locale objects
indicating, in decreasing order starting with the preferred locale, the
locales that are acceptable to the client based on the Accept-Language
header. |
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.
|
@NonNull String |
getMethod()
Returns the name of the HTTP method with which this
request was made, for example, GET, POST, or PUT.
|
String |
getParameter(String name)
Returns the value of a request parameter as a
String,
or null if the parameter does not exist. |
Map<String,String[]> |
getParameterMap()
Returns a java.util.Map of the parameters of this request.
|
Enumeration<String> |
getParameterNames()
Returns an
Enumeration of String
objects containing the names of the parameters contained
in this request. |
Map<String,List<String>> |
getParameters()
Returns a map of parameters associated with this request.
|
String[] |
getParameterValues(String name)
Returns an array of
String objects containing
all of the values the given request parameter has, or
null if the parameter does not exist. |
String |
getPathInfo()
Returns any extra path information associated with
the URL the client sent when it made this request.
|
String |
getPathTranslated()
Returns any extra path information after the servlet name
but before the query string, and translates it to a real
path.
|
String |
getProtocol()
Returns the name and version of the protocol the request uses
in the form protocol/majorVersion.minorVersion, for
example, HTTP/1.1.
|
String |
getQueryString()
Returns the query string that is contained in the request
URL after the path.
|
String |
getRemoteAddr()
Returns the Internet Protocol (IP) address of the client
or last proxy that sent the request.
|
String |
getRemoteHost()
Returns the fully qualified name of the client
or the last proxy that sent the request.
|
int |
getRemotePort()
Returns the Internet Protocol (IP) source port of the client
or last proxy that sent the request.
|
String |
getRemoteUser()
Returns the login of the user making this request, if the
user has been authenticated, or
null if the user
has not been authenticated. |
String |
getRequestedSessionId()
Returns the session ID specified by the client.
|
XPFEntitySupplier<Boolean> |
getRequestedSessionIdFromCookie()
Checks whether the requested session ID came in as a cookie.
|
XPFEntitySupplier<Boolean> |
getRequestedSessionIdFromURL()
Checks whether the requested session ID came in as part of the
request URL.
|
XPFEntitySupplier<Boolean> |
getRequestedSessionIdValid()
Checks whether the requested session ID is still valid.
|
@NonNull 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.
|
StringBuffer |
getRequestURL()
Reconstructs the URL the client used to make the request.
|
String |
getScheme()
Returns the name of the scheme used to make this request,
for example,
http, https, or ftp. |
String |
getServerName()
Returns the host name of the server to which the request was sent.
|
int |
getServerPort()
Returns the port number to which the request was sent.
|
@NonNull String |
getServletPath()
Returns the part of this request's URL that calls
the servlet.
|
XPFHttpSession |
getSession()
Returns the current
HttpSession
associated with this request or, if there is no
current session and create is true, returns
a new session. |
String |
getUserPrincipal()
Returns a
java.security.Principal object containing
the name of the current authenticated user. |
int |
hashCode() |
boolean |
isRequestedSessionIdFromCookie()
Checks whether the requested session ID came in as a cookie.
|
boolean |
isRequestedSessionIdFromURL()
Checks whether the requested session ID came in as a cookie.
|
boolean |
isRequestedSessionIdValid()
Checks whether the requested session ID is still valid.
|
boolean |
isSecure()
Returns a boolean indicating whether this request was made using a
secure channel, such as HTTPS.
|
String |
toString() |
public XPFHttpServletRequest(@NonNull
@NonNull XPFEntitySupplier<Map<String,Object>> attributes,
String characterEncoding,
int contentLength,
long contentLengthLong,
String contentType,
@NonNull
@NonNull XPFEntitySupplier<Map<String,List<String>>> parameters,
String protocol,
String scheme,
String serverName,
int serverPort,
String remoteAddr,
String remoteHost,
int remotePort,
XPFEntitySupplier<Locale> locale,
XPFEntitySupplier<Enumeration<Locale>> locales,
boolean secure,
String localName,
String localAddr,
int localPort,
String authType,
@NonNull
@NonNull String contextPath,
@NonNull
@NonNull XPFEntitySupplier<List<XPFHttpCookie>> cookies,
@NonNull
@NonNull Map<String,List<String>> headers,
@NonNull
@NonNull String method,
String pathInfo,
XPFEntitySupplier<String> pathTranslated,
String queryString,
XPFEntitySupplier<String> remoteUser,
String requestedSessionId,
@NonNull
@NonNull String requestURI,
@NonNull
@NonNull XPFEntitySupplier<StringBuffer> requestURL,
@NonNull
@NonNull String servletPath,
XPFEntitySupplier<XPFHttpSession> session,
XPFEntitySupplier<String> userPrincipal,
XPFEntitySupplier<Boolean> requestedSessionIdFromCookie,
XPFEntitySupplier<Boolean> requestedSessionIdFromURL,
XPFEntitySupplier<Boolean> requestedSessionIdValid)
@LazyLoaded public Object getAttribute(String name)
Object,
or null if no attribute of the given name exists.
Attribute names should follow the same conventions as package
names. This specification reserves names matching java.*,
javax.*, and sun.*.
name - a String specifying the name of the attributeObject containing the value of the attribute,
or null if the attribute does not exist@LazyLoaded public Enumeration<String> getAttributeNames()
Enumeration containing the
names of the attributes available to this request.
This method returns an empty Enumeration
if the request has no attributes available to it.Enumeration of strings containing the names
of the request's attributes@LazyLoaded public String getParameter(String name)
String,
or null if the parameter does not exist. Request parameters
are extra information sent with the request. For HTTP servlets,
parameters are contained in the query string or posted form data.
You should only use this method when you are sure the
parameter has only one value. If the parameter might have
more than one value, use getParameterValues(java.lang.String).
If you use this method with a multivalued
parameter, the value returned is equal to the first value
in the array returned by getParameterValues.
name - a String specifying the name of the parameterString representing the single value of
the parametergetParameterValues(java.lang.String)@LazyLoaded public Enumeration<String> getParameterNames()
Enumeration of String
objects containing the names of the parameters contained
in this request. If the request has
no parameters, the method returns an empty Enumeration.Enumeration of String
objects, each String containing the name of
a request parameter; or an empty Enumeration
if the request has no parameters@LazyLoaded public String[] getParameterValues(String name)
String objects containing
all of the values the given request parameter has, or
null if the parameter does not exist.
If the parameter has a single value, the array has a length of 1.
name - a String containing the name of
the parameter whose value is requestedString objects
containing the parameter's valuesgetParameter(java.lang.String)@LazyLoaded public Map<String,String[]> getParameterMap()
Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.
public String getHeader(String name)
String. If the request did not include a header
of the specified name, this method returns null.
If there are multiple headers with the same name, this method
returns the first head in the request.
The header name is case insensitive. You can use
this method with any request header.name - a String specifying the
header nameString containing the
value of the requested
header, or null
if the request does not
have a header of that namepublic int getIntHeader(String name)
int. If the request does not have a header
of the specified name, this method returns -1. If the
header cannot be converted to an integer, this method
throws a NumberFormatException.
The header name is case insensitive.
name - a String specifying the name
of a request headerNumberFormatException - If the header value
can't be converted
to an intpublic long getDateHeader(String name)
long value that represents a
Date object. Use this method with
headers that contain dates, such as
If-Modified-Since.
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 IllegalArgumentException.
name - a String specifying the
name of the headerlong 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
requestIllegalArgumentException - If the header value
can't be converted
to a datepublic Enumeration<String> getHeaders(String name)
Enumeration of String objects.
Some headers, such as Accept-Language can be sent
by clients as several headers each with a different value rather than
sending the header as a comma separated list.
If the request did not include any headers
of the specified name, this method returns an empty
Enumeration.
The header name is case insensitive. You can use
this method with any request header.
name - a String specifying the
header nameEnumeration 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 nullpublic Enumeration<String> getHeaderNames()
Some servlet containers do not allow
servlets to access headers using this method, in
which case this method returns null
null@LazyLoaded public Map<String,Object> getAttributes()
@LazyLoaded public Map<String,List<String>> getParameters()
@LazyLoaded public List<XPFHttpCookie> getCookies()
Cookie
objects the client sent with this request.Cookies
included with this request@LazyLoaded public XPFHttpSession getSession()
HttpSession
associated with this request or, if there is no
current session and create is true, returns
a new session.
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.
HttpSession associated
with this request or null if
the request has no valid session@LazyLoaded public Locale getLocale()
Locale that the client will
accept content in, based on the Accept-Language header.
If the client request doesn't provide an Accept-Language header,
this method returns the default locale for the server.Locale for the client@LazyLoaded public Enumeration<Locale> getLocales()
Enumeration of Locale objects
indicating, in decreasing order starting with the preferred locale, the
locales that are acceptable to the client based on the Accept-Language
header.
If the client request doesn't provide an Accept-Language header,
this method returns an Enumeration containing one
Locale, the default locale for the server.Enumeration of preferred
Locale objects for the client@LazyLoaded public String getPathTranslated()
If the URL does not have any extra path information,
this method returns null or the servlet container
cannot translate the virtual path to a real path for any reason
(such as when the web application is executed from an archive).
The web container does not decode this string.
String specifying the
real path, or null if
the URL does not have any extra path
information@LazyLoaded public String getRemoteUser()
null if the user
has not been authenticated.
Whether the user name is sent with each subsequent request
depends on the browser and type of authentication. Same as the
value of the CGI variable REMOTE_USER.String specifying the login
of the user making this request, or null
if the user login is not known@LazyLoaded public StringBuffer getRequestURL()
This method is useful for creating redirect messages and for reporting errors.
StringBuffer object containing
the reconstructed URL@LazyLoaded public String getUserPrincipal()
java.security.Principal object containing
the name of the current authenticated user. If the user has not been
authenticated, the method returns null.java.security.Principal containing
the name of the user making this request;
null if the user has not been
authenticated@LazyLoaded public boolean isRequestedSessionIdFromCookie()
true if the session ID
came in as a
cookie; otherwise, falsegetSession()@LazyLoaded public boolean isRequestedSessionIdFromURL()
true if the session ID
came in as a
cookie; otherwise, falsegetSession()@LazyLoaded public boolean isRequestedSessionIdValid()
If the client did not specify any session ID, this method returns
false.
true if this
request has an id for a valid session
in the current session context;
false otherwisegetRequestedSessionId(),
getSession()protected boolean canEqual(Object other)
public String getCharacterEncoding()
null if the request
does not specify a character encodingString containing the name of the character
encoding, or null if the request does not specify a
character encodingpublic int getContentLength()
public long getContentLengthLong()
public String getContentType()
null if the type is not known. For HTTP servlets,
same as the value of the CGI variable CONTENT_TYPE.String containing the name of the MIME type
of the request, or null if the type is not knownpublic String getProtocol()
SERVER_PROTOCOL.String containing the protocol
name and version numberpublic String getScheme()
http, https, or ftp.
Different schemes have different rules for constructing URLs,
as noted in RFC 1738.String containing the name
of the scheme used to make this requestpublic String getServerName()
Host
header value, if any, or the resolved server name, or the server IP
address.String containing the name of the serverpublic int getServerPort()
Host
header value, if any, or the server port where the client connection
was accepted on.public String getRemoteAddr()
REMOTE_ADDR.String containing the
IP address of the client that sent the requestpublic String getRemoteHost()
REMOTE_HOST.String containing the fully
qualified name of the clientpublic int getRemotePort()
public boolean isSecure()
public String getLocalName()
String containing the host
name of the IP on which the request was received.public String getLocalAddr()
String containing the
IP address on which the request was received.public int getLocalPort()
public String getAuthType()
null is returned.
Same as the value of the CGI variable AUTH_TYPE.
null if the request was
not authenticated.@NonNull public @NonNull String getContextPath()
String specifying the
portion of the request URI that indicates the context
of the request@NonNull public @NonNull Map<String,List<String>> getHeaders()
Accept-Language can be sent
by clients as several headers each with a different value rather than
sending the header as a comma separated list.
The header name is case insensitive. You can use
this method with any request header.@NonNull public @NonNull String getMethod()
String
specifying the name
of the method with which
this request was madepublic String getPathInfo()
This method returns null if there
was no extra path information.
Same as the value of the CGI variable PATH_INFO.
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 informationpublic String getQueryString()
null
if the URL does not have a query string. Same as the value
of the CGI variable QUERY_STRING.String containing the query
string or null if the URL
contains no query string. The value is not
decoded by the container.public String getRequestedSessionId()
null.String specifying the session
ID, or null if the request did
not specify a session IDisRequestedSessionIdValid()@NonNull public @NonNull String getRequestURI()
| First line of HTTP request | Returned Value | |
|---|---|---|
| POST /some/path.html HTTP/1.1 | /some/path.html | |
| GET http://foo.bar/a.html HTTP/1.0 | /a.html | |
| HEAD /xyz?a=b HTTP/1.1 | /xyz |
String containing
the part of the URL from the
protocol name up to the query string@NonNull public @NonNull String getServletPath()
This method will return an empty string ("") if the servlet used to process this request was matched using the "/*" pattern.
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.public XPFEntitySupplier<Boolean> getRequestedSessionIdFromCookie()
true if the session ID
came in as a
cookie; otherwise, falsegetSession()public XPFEntitySupplier<Boolean> getRequestedSessionIdFromURL()
true if the session ID
came in as part of a URL; otherwise,
falsegetSession()public XPFEntitySupplier<Boolean> getRequestedSessionIdValid()
If the client did not specify any session ID, this method returns
false.
true if this
request has an id for a valid session
in the current session context;
false otherwisegetRequestedSessionId(),
getSession()Copyright © 2025. All rights reserved.