| java.lang.Object com.meterware.servletunit.ServletUnitHttpRequest
ServletUnitHttpRequest | class ServletUnitHttpRequest implements HttpServletRequest(Code) | | This class represents a servlet request created from a WebRequest.
|
Inner Class :static class PrioritizedLocale implements Comparable | |
Method Summary | |
public Object | getAttribute(String name) Returns the value of the named attribute as an Object .
This method allows the servlet engine to give the servlet
custom information about a request. | public Enumeration | getAttributeNames() Returns an Enumeration containing the
names of the attributes available to this request. | public String | getAuthType() Returns the name of the authentication scheme used to protect the servlet, for example, "BASIC" or "SSL,"
or null if the servlet was not protected. | public String | getCharacterEncoding() Returns the name of the character encoding style used in this
request. | public int | getContentLength() Returns the length, in bytes, of the content contained in the
request and sent by way of the input stream or -1 if the
length is not known. | public String | getContentType() Returns the MIME type of the content of the request, or
null if the type is not known. | 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. | public Cookie[] | getCookies() Returns an array containing all of the Cookie objects the client sent with this request. | public long | getDateHeader(String name) Returns the value of the specified request header as a 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. | public String | getHeader(String name) Returns the value of the specified request header as a String. | public Enumeration | getHeaderNames() Returns an enumeration of all the header names this request contains. | public java.util.Enumeration | getHeaders(String name) Returns all the values of the specified request header as an Enumeration of String objects. | public ServletInputStream | getInputStream() Retrieves binary data from the body of the request as
a
ServletInputStream , which
gives you the ability to read one line at a time. | public int | getIntHeader(String name) Returns the value of the specified request header as an int. | public String | getLocalAddr() | public String | getLocalName() | public int | getLocalPort() | public Locale | getLocale() Returns the preferred Locale that the client will accept content in, based on the Accept-Language header. | public java.util.Enumeration | 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. | public String | getMethod() Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. | public String | getParameter(String name) Returns the value of a request parameter as a String ,
or null if the parameter does not exist. | public Map | getParameterMap() Returns a java.util.Map of the parameters of this request.
Request parameters are extra information sent with the request. | public Enumeration | getParameterNames() Returns an Enumeration of String
objects containing the names of the parameters contained
in this request. | public 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. | public String | getPathInfo() Returns any extra path information associated with the URL the client sent when it made this request. | public String | getPathTranslated() Returns any extra path information after the servlet name but before the query string,
and translates it to a real path. | public String | getProtocol() Returns the name and version of the protocol the request uses
in the form protocol/majorVersion.minorVersion, for
example, HTTP/1.1. | public String | getQueryString() Returns the query string that is contained in the request URL after the path. | public BufferedReader | getReader() Returns the body of the request as a BufferedReader
that translates character set encodings. | public String | getRealPath(String path) | public String | getRemoteAddr() Returns the Internet Protocol (IP) address of the client
that sent the request. | public String | getRemoteHost() Returns the fully qualified name of the client that sent the
request. | public int | getRemotePort() | public 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. | public RequestDispatcher | getRequestDispatcher(String path) Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.
A RequestDispatcher object can be used to forward a request to the resource or to include the
resource in a response. | 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. | public StringBuffer | getRequestURL() Reconstructs the URL the client used to make the request. | public String | getRequestedSessionId() Returns the session ID specified by the client. | public String | getScheme() Returns the name of the scheme used to make this request,
for example,
http , https , or ftp . | public String | getServerName() Returns the host name of the server that received the request. | public int | getServerPort() Returns the port number on which this request was received. | public String | getServletPath() Returns the part of this request's URL that calls the servlet. | public HttpSession | getSession(boolean create) Returns the current HttpSession associated with this request or, if there is no current session
and create is true, returns a new session. | public HttpSession | getSession() Returns the current session associated with this request, or if the request does not have a session, creates one. | public java.security.Principal | getUserPrincipal() Returns a java.security.Principal object containing the name of the current authenticated user. | public boolean | isRequestedSessionIdFromCookie() Checks whether the requested session ID came in as a cookie. | public boolean | isRequestedSessionIdFromURL() Checks whether the requested session ID came in as part of the request URL. | public boolean | isRequestedSessionIdFromUrl() | public boolean | isRequestedSessionIdValid() Checks whether the requested session ID is still valid. | public boolean | isSecure() Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS. | public boolean | isUserInRole(String role) Returns a boolean indicating whether the authenticated user is included in the specified
logical "role". | void | readBasicAuthentication() | void | readFormAuthentication() | void | recordAuthenticationInfo(String userName, String[] roles) | public void | removeAttribute(String name) Removes an attribute from this request. | public void | setAttribute(String key, Object o) Stores an attribute in the context of this request. | public void | setCharacterEncoding(String charset) Overrides the name of the character encoding used in the body of this request. | static String[] | toArray(String roleList) |
getAttribute | public Object getAttribute(String name)(Code) | | Returns the value of the named attribute as an Object .
This method allows the servlet engine to give the servlet
custom information about a request. This method returns
null if no attribute of the given name exists.
|
getAttributeNames | public Enumeration getAttributeNames()(Code) | | Returns an 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.
|
getAuthType | public String getAuthType()(Code) | | Returns the name of the authentication scheme used to protect the servlet, for example, "BASIC" or "SSL,"
or null if the servlet was not protected.
|
getCharacterEncoding | public String getCharacterEncoding()(Code) | | Returns the name of the character encoding style used in this
request. This method returns null if the request
does not use character encoding.
|
getContentLength | public int getContentLength()(Code) | | Returns the length, in bytes, of the content contained in the
request and sent by way of the input stream or -1 if the
length is not known.
|
getContentType | public String getContentType()(Code) | | Returns the MIME type of the content of the request, or
null if the type is not known. Same as the value
of the CGI variable CONTENT_TYPE.
|
getContextPath | public String getContextPath()(Code) | | 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 "".
|
getCookies | public Cookie[] getCookies()(Code) | | Returns an array containing all of the Cookie objects the client sent with this request.
This method returns null if no cookies were sent.
|
getDateHeader | public long getDateHeader(String name)(Code) | | Returns the value of the specified request header as a 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.
|
getHeader | public String getHeader(String name)(Code) | | Returns the value of the specified request header as a String. If the request did not include
a header of the specified name, this method returns null. The header name is case insensitive.
You can use this method with any request header.
|
getHeaderNames | public Enumeration getHeaderNames()(Code) | | 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 do not allow servlets to access headers using this method,
in which case this method returns null.
|
getIntHeader | public int getIntHeader(String name)(Code) | | Returns the value of the specified request header as an 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.
|
getLocalPort | public int getLocalPort()(Code) | | |
getLocale | public Locale getLocale()(Code) | | Returns the preferred 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.
|
getLocales | public java.util.Enumeration getLocales()(Code) | | 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.
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.
|
getMethod | public String getMethod()(Code) | | Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
|
getParameter | public String getParameter(String name)(Code) | | Returns the value of a request parameter as a String ,
or null if the parameter does not exist. Request parameters
are extra information sent with the request.
|
getParameterMap | public Map getParameterMap()(Code) | | Returns a java.util.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.
since: 1.3 |
getParameterNames | public Enumeration getParameterNames()(Code) | | Returns an Enumeration of String
objects containing the names of the parameters contained
in this request. If the request has
no parameters or if the input stream is empty, returns an
empty Enumeration . The input stream is empty
when all the data returned by
ServletUnitHttpRequest.getInputStream has
been read.
|
getParameterValues | public String[] getParameterValues(String name)(Code) | | Returns an array of String objects containing
all of the values the
given request parameter has, or null if the
parameter does not exist. For example, in an HTTP servlet,
this method returns an array of String objects
containing the values of a query string or posted form.
|
getPathInfo | public String getPathInfo()(Code) | | 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.
This method returns null if there was no extra path information.
|
getPathTranslated | public String getPathTranslated()(Code) | | Returns any extra path information after the servlet name but before the query string,
and translates it to a real path. If the URL does not have any extra path information, this method returns null.
|
getProtocol | public String getProtocol()(Code) | | Returns the name and version of the protocol the request uses
in the form protocol/majorVersion.minorVersion, for
example, HTTP/1.1.
|
getQueryString | public String getQueryString()(Code) | | Returns the query string that is contained in the request URL after the path.
|
getReader | public BufferedReader getReader() throws IOException(Code) | | Returns the body of the request as a BufferedReader
that translates character set encodings.
|
getRemoteAddr | public String getRemoteAddr()(Code) | | Returns the Internet Protocol (IP) address of the client
that sent the request.
|
getRemoteHost | public String getRemoteHost()(Code) | | Returns the fully qualified name of the client that sent the
request.
|
getRemotePort | public int getRemotePort()(Code) | | |
getRemoteUser | public String getRemoteUser()(Code) | | Returns the login of the user making this request, if the user has been authenticated,
or 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.
|
getRequestDispatcher | public RequestDispatcher getRequestDispatcher(String path)(Code) | | Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.
A RequestDispatcher object can be used to forward a request to the resource or to include the
resource in a response. The resource can be dynamic or static.
The pathname specified may be relative, although it cannot extend outside the current servlet
context. If the path begins with a "/" it is interpreted as relative to the current context root.
This method returns null if the servlet container cannot return a RequestDispatcher.
The difference between this method and ServletContext.getRequestDispatcher(java.lang.String)
is that this method can take a relative path.
|
getRequestURI | public String getRequestURI()(Code) | | 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.
|
getRequestURL | public StringBuffer getRequestURL()(Code) | | 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 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.
since: 1.3 |
getRequestedSessionId | public String getRequestedSessionId()(Code) | | Returns the session ID specified by the client. This may not be the same as the ID of the actual session in use.
For example, if the request specified an old (expired) session ID and the server has started a new session,
this method gets a new session with a new ID. If the request did not specify a session ID, this method returns null.
|
getScheme | public String getScheme()(Code) | | Returns the name of the scheme used to make this request,
for example,
http , https , or ftp .
Different schemes have different rules for constructing URLs,
as noted in RFC 1738.
|
getServerName | public String getServerName()(Code) | | Returns the host name of the server that received the request.
|
getServerPort | public int getServerPort()(Code) | | Returns the port number on which this request was received.
|
getServletPath | public String getServletPath()(Code) | | Returns the part of this request's URL that calls the servlet. This includes either the servlet name
or a path to the servlet, but does not include any extra path information or a query string.
|
getSession | public HttpSession getSession(boolean create)(Code) | | Returns the current HttpSession associated with this request or, if there is no current session
and create is true, returns a new session.
If create is false and the request has no valid HttpSession, this method returns null.
|
getSession | public HttpSession getSession()(Code) | | Returns the current session associated with this request, or if the request does not have a session, creates one.
|
getUserPrincipal | public java.security.Principal getUserPrincipal()(Code) | | Returns a java.security.Principal object containing the name of the current authenticated user.
If the user has not been authenticated, the method returns null.
|
isRequestedSessionIdFromCookie | public boolean isRequestedSessionIdFromCookie()(Code) | | Checks whether the requested session ID came in as a cookie.
|
isRequestedSessionIdFromURL | public boolean isRequestedSessionIdFromURL()(Code) | | Checks whether the requested session ID came in as part of the request URL.
|
isRequestedSessionIdFromUrl | public boolean isRequestedSessionIdFromUrl()(Code) | | |
isRequestedSessionIdValid | public boolean isRequestedSessionIdValid()(Code) | | Checks whether the requested session ID is still valid.
|
isSecure | public boolean isSecure()(Code) | | Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
|
isUserInRole | public boolean isUserInRole(String role)(Code) | | 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 false.
|
readBasicAuthentication | void readBasicAuthentication()(Code) | | |
readFormAuthentication | void readFormAuthentication()(Code) | | |
recordAuthenticationInfo | void recordAuthenticationInfo(String userName, String[] roles)(Code) | | |
removeAttribute | public void removeAttribute(String name)(Code) | | Removes an attribute from this request. This method is not generally needed
as attributes only persist as long as the request is being handled.
|
setAttribute | public void setAttribute(String key, Object o)(Code) | | Stores an attribute in the context of this request.
Attributes are reset between requests.
|
setCharacterEncoding | public void setCharacterEncoding(String charset) throws UnsupportedEncodingException(Code) | | 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().
since: 1.3 |
|
|