|
|||||||||
| Home >> All >> [ servletunit overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
servletunit
Class HttpServletRequestSimulator

java.lang.Objectservletunit.HttpServletRequestSimulator
- All Implemented Interfaces:
- javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest
- public class HttpServletRequestSimulator
- extends java.lang.Object
- implements javax.servlet.http.HttpServletRequest
- extends java.lang.Object
| Fields inherited from interface javax.servlet.http.HttpServletRequest |
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH |
| Constructor Summary | |
HttpServletRequestSimulator(javax.servlet.ServletContext context)
|
|
| Method Summary | |
void |
addCookie(javax.servlet.http.Cookie cookie)
Adds a cookie that can be retrieved from this request via the getCookies() method. |
void |
addParameter(java.lang.String key,
java.lang.String value)
Adds a parameter to this object's list of parameters |
void |
addParameter(java.lang.String name,
java.lang.String[] values)
Adds a parameter as a String array to this object's list of parameters |
java.lang.Object |
getAttribute(java.lang.String s)
Returns the value of the named attribute as an Object,
or null if no attribute of the given name exists. |
java.util.Enumeration |
getAttributeNames()
Returns an Enumeration containing the
names of the attributes available to this request. |
java.lang.String |
getAuthType()
Returns the name of the authentication scheme used to protect the servlet. |
java.lang.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. |
java.lang.String |
getContentType()
Returns the MIME type of the body of the request, or null if the type is not known. |
java.lang.String |
getContextPath()
Returns the portion of the request URI that indicates the context of the request. |
javax.servlet.http.Cookie[] |
getCookies()
Returns an array containing all of the Cookie
objects the client sent with this request. |
long |
getDateHeader(java.lang.String name)
Returns the value of the specified request header as a long value that represents a Date object. |
java.lang.String |
getHeader(java.lang.String s)
Returns the value of the specified request header as a String. |
java.util.Enumeration |
getHeaderNames()
Returns an enumeration of all the header names this request contains. |
java.util.Enumeration |
getHeaders(java.lang.String s)
This operation is not supported. |
javax.servlet.ServletInputStream |
getInputStream()
This operation is not supported. |
int |
getIntHeader(java.lang.String s)
Returns the value of the specified request header as an int. |
java.lang.String |
getLocalAddr()
Returns the Internet Protocol (IP) address of the interface on which the request was received. |
java.util.Locale |
getLocale()
Returns the preferred Locale that the client will
accept content in, based on the Accept-Language header. |
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. |
java.lang.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. |
java.lang.String |
getMethod()
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. |
java.lang.String |
getParameter(java.lang.String s)
Returns the value of a request parameter as a String,
or null if the parameter does not exist. |
java.util.Map |
getParameterMap()
Returns a java.util.Map of the parameters of this request. |
java.util.Enumeration |
getParameterNames()
Returns an Enumeration of String
objects containing the names of the parameters contained
in this request. |
java.lang.String[] |
getParameterValues(java.lang.String s)
Returns an array of String objects containing
all of the values the given request parameter has, or
null if the parameter does not exist. |
java.lang.String |
getPathInfo()
Returns any extra path information associated with the URL the client sent when it made this request. |
java.lang.String |
getPathTranslated()
This operation is not supported. |
java.lang.String |
getProtocol()
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1. |
java.lang.String |
getQueryString()
Returns the query string that is contained in the request URL after the path. |
java.io.BufferedReader |
getReader()
This operation is not supported. |
java.lang.String |
getRealPath(java.lang.String path)
Deprecated. As of Version 2.1 of the Java Servlet API, use ServletContext.getRealPath(java.lang.String)> ServletContext.getRealPath(java.lang.String) 55 instead. |
java.lang.String |
getRemoteAddr()
Returns the Internet Protocol (IP) address of the client that sent the request. |
java.lang.String |
getRemoteHost()
Returns the fully qualified name of the client that sent the request. |
int |
getRemotePort()
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request. |
java.lang.String |
getRemoteUser()
Returns the fully qualified name of the client that sent the request. |
javax.servlet.RequestDispatcher |
getRequestDispatcher(java.lang.String url)
Returns a javax.servlet.RequestDispatcher object that acts as a wrapper for the resource located at the given path. |
java.lang.String |
getRequestedSessionId()
Returns the session ID specified by the client. |
java.lang.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. |
java.lang.StringBuffer |
getRequestURL()
Reconstructs the URL the client used to make the request. |
java.lang.String |
getScheme()
Returns the name of the scheme used to make this request, for example, http, https, or ftp. |
java.lang.String |
getServerName()
Returns the host name of the server that received the request. |
int |
getServerPort()
Returns the port number on which this request was received. |
java.lang.String |
getServletPath()
Returns the part of this request's URL that calls the servlet. |
javax.servlet.http.HttpSession |
getSession()
Returns the current session associated with this request, or if the request does not have a session, creates one. |
javax.servlet.http.HttpSession |
getSession(boolean b)
Returns the current HttpSession
associated with this request or, if if there is no
current session and create is true, returns
a new session. |
java.security.Principal |
getUserPrincipal()
Returns a java.security.Principal object containing
the name of the current authenticated user. |
boolean |
isRequestedSessionIdFromCookie()
Checks whether the requested session ID came in as a cookie. |
boolean |
isRequestedSessionIdFromUrl()
Deprecated. As of Version 2.1 of the Java Servlet API, use isRequestedSessionIdFromURL() 55
instead. |
boolean |
isRequestedSessionIdFromURL()
Checks whether the requested session ID came in as part of the request URL. |
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. |
boolean |
isUserInRole(java.lang.String s)
Returns a boolean indicating whether the authenticated user is included in the specified logical "role". |
void |
removeAttribute(java.lang.String s)
Removes an attribute from this request. |
void |
setAttribute(java.lang.String name,
java.lang.Object o)
Stores an attribute in this request. |
void |
setAuthType(java.lang.String s)
Sets authentication scheme to be used in getAuthType() 55 . |
void |
setCharacterEncoding(java.lang.String s)
Sets character encoding to be used in getCharacterEncoding() 55 . |
void |
setContentType(java.lang.String s)
Sets content type to be used in getContentType() 55 . |
void |
setContextPath(java.lang.String s)
Sets the context path to be used by getContextPath() 55 . |
void |
setCookies(javax.servlet.http.Cookie[] cookies)
Adds a set of cookies that can be retrieved from this request via the getCookies() method. |
void |
setDateHeader(java.lang.String name,
long millis)
Sets a header with the appropriate date string given the time in milliseconds. |
void |
setHeader(java.lang.String key,
java.lang.String value)
Sets a header to be used in getHeader(java.lang.String) 55 . |
void |
setLocalAddr(java.lang.String localAddr)
|
void |
setLocale(java.util.Locale locale)
Sets the locale to be used by getLocale() 55 . |
void |
setLocalName(java.lang.String localName)
|
void |
setLocalPort(int localPort)
|
void |
setMethod(int methodType)
Sets the name of the HTTP method with which this request was made. |
void |
setParameterValue(java.lang.String key,
java.lang.String[] value)
Sets parameter value to be used by getParameter(java.lang.String) 55 . |
void |
setPathInfo(java.lang.String s)
Sets path information to be used by getPathInfo() 55 . |
void |
setQueryString(java.lang.String s)
Sets query string to be used by getQueryString() 55 . |
void |
setRemoteAddr(java.lang.String remoteAddr)
Sets remote address to be used by getRemoteAddr() 55 . |
void |
setRemoteHost(java.lang.String remoteHost)
Sets remote host to be used by getRemoteHost() 55 . |
void |
setRemotePort(int remotePort)
|
void |
setRemoteUser(java.lang.String remoteUser)
Sets remote user to be used by getRemoteUser() 55 . |
void |
setRequestedSessionId(java.lang.String s)
Sets requested session ID to be used by getRequestedSessionId() 55 . |
void |
setRequestURI(java.lang.String requestURI)
Sets request URI to be used by getRequestURI() 55 . |
void |
setRequestURL(java.lang.String url)
Sets the request URL to be used in this test. |
void |
setScheme(java.lang.String s)
Sets scheme to be used by getScheme() 55 . |
void |
setServerName(java.lang.String s)
Sets server name to be used by getServerName() 55 . |
void |
setServerPort(int port)
Sets the server port to be used with . |
void |
setServletPath(java.lang.String s)
Sets servlet path to be used by getServletPath() 55 . |
void |
setUserPrincipal(java.security.Principal principal)
Sets the Principal used by getUserPrincipal() 55 . |
void |
setUserRole(java.lang.String role)
Sets user role to be used in isUserInRole(java.lang.String) 55 |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
attributes
private java.util.Hashtable attributes
scheme
private java.lang.String scheme
protocol
private java.lang.String protocol
requestURI
private java.lang.String requestURI
requestURL
private java.lang.String requestURL
contextPath
private java.lang.String contextPath
servletPath
private java.lang.String servletPath
pathInfo
private java.lang.String pathInfo
queryString
private java.lang.String queryString
method
private java.lang.String method
contentType
private java.lang.String contentType
locale
private java.util.Locale locale
principal
private java.security.Principal principal
remoteAddr
java.lang.String remoteAddr
localAddr
java.lang.String localAddr
remoteHost
java.lang.String remoteHost
localName
java.lang.String localName
remotePort
int remotePort
localPort
int localPort
remoteUser
private java.lang.String remoteUser
userRole
private java.lang.String userRole
reqSessionId
private java.lang.String reqSessionId
authType
java.lang.String authType
charEncoding
java.lang.String charEncoding
serverName
private java.lang.String serverName
port
private int port
parameters
private java.util.Hashtable parameters
headers
private java.util.Hashtable headers
cookies
private java.util.Vector cookies
session
private javax.servlet.http.HttpSession session
context
private javax.servlet.ServletContext context
GET
public static final int GET
- Constant used by
setMethod(int)55 to indicate that the GET method made this request.- See Also:
- Constant Field Values
POST
public static final int POST
- Constant used by
setMethod(int)55 to indicate that the POST method made this request.- See Also:
- Constant Field Values
PUT
public static final int PUT
- Constant used by
setMethod(int)55 to indicate that the PUT method made this request.- See Also:
- Constant Field Values
| Constructor Detail |
HttpServletRequestSimulator
public HttpServletRequestSimulator(javax.servlet.ServletContext context)
| Method Detail |
addParameter
public void addParameter(java.lang.String key, java.lang.String value)
- Adds a parameter to this object's list of parameters
addParameter
public void addParameter(java.lang.String name, java.lang.String[] values)
- Adds a parameter as a String array to this object's list of parameters
getParameterMap
public java.util.Map getParameterMap()
- 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.
- Specified by:
getParameterMapin interfacejavax.servlet.ServletRequest
getAttribute
public java.lang.Object getAttribute(java.lang.String s)
- Returns the value of the named attribute as an
Object, ornullif no attribute of the given name exists.Attributes can be set two ways. The servlet container may set attributes to make available custom information about a request. For example, for requests made using HTTPS, the attribute
javax.servlet.request.X509Certificatecan be used to retrieve information on the certificate of the client. Attributes can also be set programatically using ServletRequest.setAttribute(java.lang.String, java.lang.Object)>ServletRequest.setAttribute(java.lang.String, java.lang.Object)55 . This allows information to be embedded into a request before a javax.servlet.RequestDispatcher call.Attribute names should follow the same conventions as package names. This specification reserves names matching
java.*,javax.*, andsun.*.- Specified by:
getAttributein interfacejavax.servlet.ServletRequest
getAttributeNames
public java.util.Enumeration getAttributeNames()
- Returns an
Enumerationcontaining the names of the attributes available to this request. This method returns an emptyEnumerationif the request has no attributes available to it.- Specified by:
getAttributeNamesin interfacejavax.servlet.ServletRequest
getAuthType
public java.lang.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
nullis returned.Same as the value of the CGI variable AUTH_TYPE.
- Specified by:
getAuthTypein interfacejavax.servlet.http.HttpServletRequest
getCharacterEncoding
public java.lang.String getCharacterEncoding()
- Returns the name of the character encoding used in the body of this
request. This method returns
nullif the request does not specify a character encoding- Specified by:
getCharacterEncodingin interfacejavax.servlet.ServletRequest
getContentLength
public 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. For HTTP servlets, same as the value
of the CGI variable CONTENT_LENGTH.
- Specified by:
getContentLengthin interfacejavax.servlet.ServletRequest
getContentType
public java.lang.String getContentType()
- Returns the MIME type of the body of the request, or
nullif the type is not known. For HTTP servlets, same as the value of the CGI variable CONTENT_TYPE.- Specified by:
getContentTypein interfacejavax.servlet.ServletRequest
getContextPath
public java.lang.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.
- Specified by:
getContextPathin interfacejavax.servlet.http.HttpServletRequest
addCookie
public void addCookie(javax.servlet.http.Cookie cookie)
- Adds a cookie that can be retrieved from this request via the
getCookies() method.
setCookies
public void setCookies(javax.servlet.http.Cookie[] cookies)
- Adds a set of cookies that can be retrieved from this request via the
getCookies() method.
getCookies
public javax.servlet.http.Cookie[] getCookies()
- Returns an array containing all of the
Cookieobjects the client sent with this request. This method returnsnullif no cookies were sent.- Specified by:
getCookiesin interfacejavax.servlet.http.HttpServletRequest
getDateHeader
public long getDateHeader(java.lang.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. 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.- Specified by:
getDateHeaderin interfacejavax.servlet.http.HttpServletRequest
setDateHeader
public void setDateHeader(java.lang.String name, long millis)
- Sets a header with the appropriate date string given the time in milliseconds.
getHeader
public java.lang.String getHeader(java.lang.String s)
- 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 returnsnull. The header name is case insensitive. You can use this method with any request header.- Specified by:
getHeaderin interfacejavax.servlet.http.HttpServletRequest
getHeaderNames
public java.util.Enumeration getHeaderNames()
- 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- Specified by:
getHeaderNamesin interfacejavax.servlet.http.HttpServletRequest
getHeaders
public java.util.Enumeration getHeaders(java.lang.String s)
- This operation is not supported.
- Specified by:
getHeadersin interfacejavax.servlet.http.HttpServletRequest
getInputStream
public javax.servlet.ServletInputStream getInputStream() throws java.io.IOException
- This operation is not supported.
- Specified by:
getInputStreamin interfacejavax.servlet.ServletRequest
getIntHeader
public int getIntHeader(java.lang.String s)
- 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 aNumberFormatException.The header name is case insensitive.
- Specified by:
getIntHeaderin interfacejavax.servlet.http.HttpServletRequest
getLocale
public java.util.Locale getLocale()
- Returns the preferred
Localethat 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.- Specified by:
getLocalein interfacejavax.servlet.ServletRequest
getLocales
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. 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.
- Specified by:
getLocalesin interfacejavax.servlet.ServletRequest
getMethod
public java.lang.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.
- Specified by:
getMethodin interfacejavax.servlet.http.HttpServletRequest
getParameter
public java.lang.String getParameter(java.lang.String s)
- Returns the value of a request parameter as a
String, ornullif 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)55 .If you use this method with a multivalued parameter, the value returned is equal to the first value in the array returned by
getParameterValues.If the parameter data was sent in the request body, such as occurs with an HTTP POST request, then reading the body directly via
getInputStream()55 orgetReader()55 can interfere with the execution of this method.- Specified by:
getParameterin interfacejavax.servlet.ServletRequest
getParameterNames
public java.util.Enumeration getParameterNames()
- Returns an
EnumerationofStringobjects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an emptyEnumeration.- Specified by:
getParameterNamesin interfacejavax.servlet.ServletRequest
getParameterValues
public java.lang.String[] getParameterValues(java.lang.String s)
- Returns an array of
Stringobjects containing all of the values the given request parameter has, ornullif the parameter does not exist.If the parameter has a single value, the array has a length of 1.
- Specified by:
getParameterValuesin interfacejavax.servlet.ServletRequest
getPathInfo
public java.lang.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.
This method returns
nullif there was no extra path information.Same as the value of the CGI variable PATH_INFO.
- Specified by:
getPathInfoin interfacejavax.servlet.http.HttpServletRequest
getPathTranslated
public java.lang.String getPathTranslated()
- This operation is not supported.
- Specified by:
getPathTranslatedin interfacejavax.servlet.http.HttpServletRequest
getProtocol
public java.lang.String getProtocol()
- Returns the name and version of the protocol the request uses
in the form protocol/majorVersion.minorVersion, for
example, HTTP/1.1. For HTTP servlets, the value
returned is the same as the value of the CGI variable
SERVER_PROTOCOL.- Specified by:
getProtocolin interfacejavax.servlet.ServletRequest
getQueryString
public java.lang.String getQueryString()
- Returns the query string that is contained in the request
URL after the path. This method returns
nullif the URL does not have a query string. Same as the value of the CGI variable QUERY_STRING.- Specified by:
getQueryStringin interfacejavax.servlet.http.HttpServletRequest
getReader
public java.io.BufferedReader getReader() throws java.io.IOException
- This operation is not supported.
- Specified by:
getReaderin interfacejavax.servlet.ServletRequest
getRealPath
public java.lang.String getRealPath(java.lang.String path)
- Deprecated. As of Version 2.1 of the Java Servlet API,
use ServletContext.getRealPath(java.lang.String)>
ServletContext.getRealPath(java.lang.String)55 instead.- Specified by:
getRealPathin interfacejavax.servlet.ServletRequest
getRemoteAddr
public java.lang.String getRemoteAddr()
- Returns the Internet Protocol (IP) address of the client
that sent the request. For HTTP servlets, same as the value of the
CGI variable
REMOTE_ADDR.- Specified by:
getRemoteAddrin interfacejavax.servlet.ServletRequest
getRemoteHost
public java.lang.String getRemoteHost()
- Returns the fully qualified name of the client that sent the
request. If the engine cannot or chooses not to resolve the hostname
(to improve performance), this method returns the dotted-string form of
the IP address. For HTTP servlets, same as the value of the CGI variable
REMOTE_HOST.- Specified by:
getRemoteHostin interfacejavax.servlet.ServletRequest
getRemoteUser
public java.lang.String getRemoteUser()
- Returns the fully qualified name of the client that sent the
request. If the engine cannot or chooses not to resolve the hostname
(to improve performance), this method returns the dotted-string form of
the IP address. For HTTP servlets, same as the value of the CGI variable
REMOTE_HOST.- Specified by:
getRemoteUserin interfacejavax.servlet.http.HttpServletRequest
getRequestDispatcher
public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String url)
- Returns a javax.servlet.RequestDispatcher object that acts as a wrapper for
the resource located at the given path.
A
RequestDispatcherobject 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
nullif the servlet container cannot return aRequestDispatcher.The difference between this method and ServletContext.getRequestDispatcher(java.lang.String)>
ServletContext.getRequestDispatcher(java.lang.String)55 is that this method can take a relative path.- Specified by:
getRequestDispatcherin interfacejavax.servlet.ServletRequest
getRequestedSessionId
public java.lang.String getRequestedSessionId()
- 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.- Specified by:
getRequestedSessionIdin interfacejavax.servlet.http.HttpServletRequest
getRequestURI
public java.lang.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:
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 - Specified by:
getRequestURIin interfacejavax.servlet.http.HttpServletRequest
getRequestURL
public java.lang.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 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.- Specified by:
getRequestURLin interfacejavax.servlet.http.HttpServletRequest
getScheme
public java.lang.String getScheme()
- Returns the name of the scheme used to make this request,
for example,
http,https, orftp. Different schemes have different rules for constructing URLs, as noted in RFC 1738.- Specified by:
getSchemein interfacejavax.servlet.ServletRequest
getServerName
public java.lang.String getServerName()
- Returns the host name of the server that received
the request. For HTTP servlets, same as the value of
the CGI variable SERVER_NAME.
- Specified by:
getServerNamein interfacejavax.servlet.ServletRequest
getServerPort
public int getServerPort()
- Returns the port number on which this request was received. For HTTP servlets, same as the value of the CGI variable SERVER_PORT.
- Specified by:
getServerPortin interfacejavax.servlet.ServletRequest
setServerPort
public void setServerPort(int port)
- Sets the server port to be used with .
getServletPath
public java.lang.String getServletPath()
- 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. Same as the value
of the CGI variable SCRIPT_NAME.
- Specified by:
getServletPathin interfacejavax.servlet.http.HttpServletRequest
getSession
public javax.servlet.http.HttpSession getSession()
- Returns the current session associated with this request,
or if the request does not have a session, creates one.
- Specified by:
getSessionin interfacejavax.servlet.http.HttpServletRequest
getSession
public javax.servlet.http.HttpSession getSession(boolean b)
- Returns the current
HttpSessionassociated with this request or, if if there is no current session andcreateis true, returns a new session.If
createisfalseand the request has no validHttpSession, this method returnsnull.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.
- Specified by:
getSessionin interfacejavax.servlet.http.HttpServletRequest
getUserPrincipal
public java.security.Principal getUserPrincipal()
- Returns a
java.security.Principalobject containing the name of the current authenticated user. If the user has not been authenticated, the method returnsnull.- Specified by:
getUserPrincipalin interfacejavax.servlet.http.HttpServletRequest
isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()
- Checks whether the requested session ID came in as a cookie.
- Specified by:
isRequestedSessionIdFromCookiein interfacejavax.servlet.http.HttpServletRequest
isRequestedSessionIdFromUrl
public boolean isRequestedSessionIdFromUrl()
- Deprecated. As of Version 2.1 of the Java Servlet
API, use
isRequestedSessionIdFromURL()55 instead.- Specified by:
isRequestedSessionIdFromUrlin interfacejavax.servlet.http.HttpServletRequest
isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()
- Checks whether the requested session ID came in as part of the
request URL.
- Specified by:
isRequestedSessionIdFromURLin interfacejavax.servlet.http.HttpServletRequest
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()
- Checks whether the requested session ID is still valid.
- Specified by:
isRequestedSessionIdValidin interfacejavax.servlet.http.HttpServletRequest
isSecure
public boolean isSecure()
- Returns a boolean indicating whether this request was made using a
secure channel, such as HTTPS.
- Specified by:
isSecurein interfacejavax.servlet.ServletRequest
isUserInRole
public boolean isUserInRole(java.lang.String s)
- 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.- Specified by:
isUserInRolein interfacejavax.servlet.http.HttpServletRequest
setUserRole
public void setUserRole(java.lang.String role)
- Sets user role to be used in
isUserInRole(java.lang.String)55
removeAttribute
public void removeAttribute(java.lang.String s)
- Removes an attribute from this request. This method is not
generally needed as attributes only persist as long as the request
is being handled.
Attribute names should follow the same conventions as package names. Names beginning with
java.*,javax.*, andcom.sun.*, are reserved for use by Sun Microsystems.- Specified by:
removeAttributein interfacejavax.servlet.ServletRequest
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object o)
- Stores an attribute in this request.
Attributes are reset between requests. This method is most
often used in conjunction with javax.servlet.RequestDispatcher.
Attribute names should follow the same conventions as package names. Names beginning with
java.*,javax.*, andcom.sun.*, are reserved for use by Sun Microsystems.
If the value passed in is null, the effect is the same as callingremoveAttribute(java.lang.String)55 .- Specified by:
setAttributein interfacejavax.servlet.ServletRequest
setAuthType
public void setAuthType(java.lang.String s)
- Sets authentication scheme to be used in
getAuthType()55 .
setCharacterEncoding
public void setCharacterEncoding(java.lang.String s)
- Sets character encoding to be used in
getCharacterEncoding()55 .- Specified by:
setCharacterEncodingin interfacejavax.servlet.ServletRequest
setContentType
public void setContentType(java.lang.String s)
- Sets content type to be used in
getContentType()55 .
setHeader
public void setHeader(java.lang.String key, java.lang.String value)
- Sets a header to be used in
getHeader(java.lang.String)55 .
setMethod
public void setMethod(int methodType)
- Sets the name of the HTTP method with which this request
was made. This value will be returned in the getMethod
method.
setParameterValue
public void setParameterValue(java.lang.String key, java.lang.String[] value)
- Sets parameter value to be used by
getParameter(java.lang.String)55 .
setPathInfo
public void setPathInfo(java.lang.String s)
- Sets path information to be used by
getPathInfo()55 .
setQueryString
public void setQueryString(java.lang.String s)
- Sets query string to be used by
getQueryString()55 .
setRemoteUser
public void setRemoteUser(java.lang.String remoteUser)
- Sets remote user to be used by
getRemoteUser()55 .
setRemoteAddr
public void setRemoteAddr(java.lang.String remoteAddr)
- Sets remote address to be used by
getRemoteAddr()55 .
setRemoteHost
public void setRemoteHost(java.lang.String remoteHost)
- Sets remote host to be used by
getRemoteHost()55 .
setRequestedSessionId
public void setRequestedSessionId(java.lang.String s)
- Sets requested session ID to be used by
getRequestedSessionId()55 .
setRequestURI
public void setRequestURI(java.lang.String requestURI)
- Sets request URI to be used by
getRequestURI()55 .
setRequestURL
public void setRequestURL(java.lang.String url)
- Sets the request URL to be used in this test. This method uses
the given request URL to also set the scheme, server name, server
port, request URI, and query string.
setScheme
public void setScheme(java.lang.String s)
- Sets scheme to be used by
getScheme()55 .
setServletPath
public void setServletPath(java.lang.String s)
- Sets servlet path to be used by
getServletPath()55 .
setServerName
public void setServerName(java.lang.String s)
- Sets server name to be used by
getServerName()55 .
setContextPath
public void setContextPath(java.lang.String s)
- Sets the context path to be used by
getContextPath()55 .
setLocale
public void setLocale(java.util.Locale locale)
- Sets the locale to be used by
getLocale()55 .
setUserPrincipal
public void setUserPrincipal(java.security.Principal principal)
- Sets the Principal used by
getUserPrincipal()55 .
getRemotePort
public int getRemotePort()
- Description copied from interface:
javax.servlet.ServletRequest - Returns the Internet Protocol (IP) source port of the client
or last proxy that sent the request.
- Specified by:
getRemotePortin interfacejavax.servlet.ServletRequest
setRemotePort
public void setRemotePort(int remotePort)
getLocalAddr
public java.lang.String getLocalAddr()
- Description copied from interface:
javax.servlet.ServletRequest - Returns the Internet Protocol (IP) address of the interface on
which the request was received.
- Specified by:
getLocalAddrin interfacejavax.servlet.ServletRequest
setLocalAddr
public void setLocalAddr(java.lang.String localAddr)
getLocalName
public java.lang.String getLocalName()
- Description copied from interface:
javax.servlet.ServletRequest - Returns the host name of the Internet Protocol (IP) interface on
which the request was received.
- Specified by:
getLocalNamein interfacejavax.servlet.ServletRequest
setLocalName
public void setLocalName(java.lang.String localName)
getLocalPort
public int getLocalPort()
- Description copied from interface:
javax.servlet.ServletRequest - Returns the Internet Protocol (IP) port number of the interface
on which the request was received.
- Specified by:
getLocalPortin interfacejavax.servlet.ServletRequest
setLocalPort
public void setLocalPort(int localPort)
|
|||||||||
| Home >> All >> [ servletunit overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | | ||||||||
JAVADOC
servletunit.HttpServletRequestSimulator