org.apache.catalina.core

Class DummyRequest

Implemented Interfaces:
HttpRequest, HttpServletRequest, Request

public class DummyRequest
extends java.lang.Object
implements HttpRequest, HttpServletRequest

Dummy request object, used for request dispatcher mapping, as well as JSP precompilation.

Version:
$Revision: 1.10 $ $Date: 2004/02/27 14:58:42 $

Author:
Remy Maucherat

Field Summary

protected String
contextPath
protected String
decodedURI
protected FilterChain
filterChain
protected String
pathInfo
protected String
queryString
protected String
servletPath
protected ValveContext
valveContext
protected Wrapper
wrapper

Constructor Summary

DummyRequest()
DummyRequest(String contextPath, String decodedURI, String queryString)

Method Summary

void
addCookie(Cookie cookie)
Add a Cookie to the set of Cookies associated with this Request.
void
addHeader(String name, String value)
Add a Header to the set of Headers associated with this Request.
void
addLocale(Locale locale)
Add a Locale to the set of preferred Locales for this Request.
void
addParameter(String name, values[] )
Add a parameter name and corresponding set of values to this Request.
void
clearCookies()
Clear the collection of Cookies associated with this Request.
void
clearHeaders()
Clear the collection of Headers associated with this Request.
void
clearLocales()
Clear the collection of Locales associated with this Request.
void
clearParameters()
Clear the collection of parameters associated with this Request.
ServletInputStream
createInputStream()
Create and return a ServletInputStream to read the content associated with this Request.
void
finishRequest()
Perform whatever actions are required to flush and close the input stream or reader, in a single operation.
Object
getAttribute(String name)
Enumeration
getAttributeNames()
String
getAuthType()
String
getAuthorization()
Return the authorization credentials sent with this request.
String
getCharacterEncoding()
Connector
getConnector()
Return the Connector through which this Request was received.
int
getContentLength()
String
getContentType()
Context
getContext()
Return the Context within which this Request is being processed.
String
getContextPath()
MessageBytes
getContextPathMB()
Get the context path.
Cookie[]
getCookies()
long
getDateHeader(String name)
String
getDecodedRequestURI()
Get the decoded request URI.
MessageBytes
getDecodedRequestURIMB()
Get the decoded request URI.
FilterChain
getFilterChain()
Get filter chain associated with the request.
String
getHeader(String name)
Enumeration
getHeaderNames()
Enumeration
getHeaders(String name)
Host
getHost()
Return the Host within which this Request is being processed.
String
getInfo()
Return descriptive information about this Request implementation and the corresponding version number, in the format <description>/<version>.
ServletInputStream
getInputStream()
int
getIntHeader(String name)
String
getLocalAddr()
String
getLocalName()
int
getLocalPort()
Locale
getLocale()
Enumeration
getLocales()
String
getMethod()
Object
getNote(String name)
Return the object bound with the specified name to the internal notes for this request, or null if no such binding exists.
Iterator
getNoteNames()
Return an Iterator containing the String names of all notes bindings that exist for this request.
String
getParameter(String name)
Map
getParameterMap()
Enumeration
getParameterNames()
String[]
getParameterValues(String name)
String
getPathInfo()
MessageBytes
getPathInfoMB()
Get the path info.
String
getPathTranslated()
String
getProtocol()
String
getQueryString()
BufferedReader
getReader()
String
getRealPath(String path)
String
getRemoteAddr()
String
getRemoteHost()
int
getRemotePort()
String
getRemoteUser()
ServletRequest
getRequest()
Return the ServletRequest for which this object is the facade.
RequestDispatcher
getRequestDispatcher(String path)
MessageBytes
getRequestPathMB()
Get the request path.
String
getRequestURI()
StringBuffer
getRequestURL()
String
getRequestedSessionId()
Response
getResponse()
Return the Response with which this Request is associated.
String
getScheme()
String
getServerName()
int
getServerPort()
String
getServletPath()
MessageBytes
getServletPathMB()
Get the servlet path.
HttpSession
getSession()
HttpSession
getSession(boolean create)
Socket
getSocket()
Return the Socket (if any) through which this Request was received.
InputStream
getStream()
Return the input stream associated with this Request.
Principal
getUserPrincipal()
ValveContext
getValveContext()
Get valve context.
Wrapper
getWrapper()
Return the Wrapper within which this Request is being processed.
boolean
isRequestedSessionIdFromCookie()
boolean
isRequestedSessionIdFromURL()
boolean
isRequestedSessionIdFromUrl()
boolean
isRequestedSessionIdValid()
boolean
isSecure()
boolean
isUserInRole(String role)
void
recycle()
Release all object references, and initialize instance variables, in preparation for reuse of this object.
void
removeAttribute(String name)
void
removeNote(String name)
Remove any object bound to the specified name in the internal notes for this request.
void
setAttribute(String name, Object value)
void
setAuthType(String authType)
Set the authentication type used for this request, if any; otherwise set the type to null.
void
setAuthorization(String authorization)
Set the authorization credentials sent with this request.
void
setCharacterEncoding(String enc)
void
setConnector(Connector connector)
Set the Connector through which this Request was received.
void
setContentLength(int length)
Set the content length associated with this Request.
void
setContentType(String type)
Set the content type (and optionally the character encoding) associated with this Request.
void
setContext(Context context)
Set the Context within which this Request is being processed.
void
setContextPath(String path)
Set the context path for this Request.
void
setDecodedRequestURI(String uri)
Set the decoded request URI.
void
setFilterChain(FilterChain filterChain)
Set filter chain associated with the request.
void
setHost(Host host)
Set the Host within which this Request is being processed.
void
setMethod(String method)
Set the HTTP request method used for this Request.
void
setNote(String name, Object value)
Bind an object to a specified name in the internal notes associated with this request, replacing any existing binding for this name.
void
setPathInfo(String path)
Set the path information for this Request.
void
setProtocol(String protocol)
Set the protocol name and version associated with this Request.
void
setQueryString(String query)
Set the query string for this Request.
void
setRemoteAddr(String remoteAddr)
Set the remote IP address associated with this Request.
void
setRemoteHost(String remoteHost)
void
setRequestURI(String uri)
Set the unparsed request URI for this Request.
void
setRequestedSessionCookie(boolean flag)
Set a flag indicating whether or not the requested session ID for this request came in through a cookie.
void
setRequestedSessionId(String id)
Set the requested session ID for this request.
void
setRequestedSessionURL(boolean flag)
Set a flag indicating whether or not the requested session ID for this request came in through a URL.
void
setResponse(Response response)
Set the Response with which this Request is associated.
void
setScheme(String scheme)
Set the name of the scheme associated with this request.
void
setSecure(boolean secure)
Set the value to be returned by isSecure() for this Request.
void
setServerName(String name)
Set the name of the server (virtual host) to process this request.
void
setServerPort(int port)
Set the port number of the server to process this request.
void
setServletPath(String path)
Set the servlet path for this Request.
void
setSocket(Socket socket)
Set the Socket (if any) through which this Request was received.
void
setStream(InputStream input)
Set the input stream associated with this Request.
void
setUserPrincipal(Principal principal)
Set the Principal who has been authenticated for this Request.
void
setValveContext(ValveContext valveContext)
Set valve context.
void
setWrapper(Wrapper wrapper)
Set the Wrapper within which this Request is being processed.

Field Details

contextPath

protected String contextPath


decodedURI

protected String decodedURI


filterChain

protected FilterChain filterChain


pathInfo

protected String pathInfo


queryString

protected String queryString


servletPath

protected String servletPath


valveContext

protected ValveContext valveContext


wrapper

protected Wrapper wrapper

Constructor Details

DummyRequest

public DummyRequest()


DummyRequest

public DummyRequest(String contextPath,
                    String decodedURI,
                    String queryString)

Method Details

addCookie

public void addCookie(Cookie cookie)
Add a Cookie to the set of Cookies associated with this Request.
Specified by:
addCookie in interface HttpRequest

Parameters:
cookie - The new cookie


addHeader

public void addHeader(String name,
                      String value)
Add a Header to the set of Headers associated with this Request.
Specified by:
addHeader in interface HttpRequest

Parameters:
name - The new header name
value - The new header value


addLocale

public void addLocale(Locale locale)
Add a Locale to the set of preferred Locales for this Request. The first added Locale will be the first one returned by getLocales().
Specified by:
addLocale in interface HttpRequest

Parameters:
locale - The new preferred Locale


addParameter

public void addParameter(String name,
                         values[] )
Add a parameter name and corresponding set of values to this Request. (This is used when restoring the original request on a form based login).
Specified by:
addParameter in interface HttpRequest

Parameters:
name - Name of this request parameter


clearCookies

public void clearCookies()
Clear the collection of Cookies associated with this Request.
Specified by:
clearCookies in interface HttpRequest


clearHeaders

public void clearHeaders()
Clear the collection of Headers associated with this Request.
Specified by:
clearHeaders in interface HttpRequest


clearLocales

public void clearLocales()
Clear the collection of Locales associated with this Request.
Specified by:
clearLocales in interface HttpRequest


clearParameters

public void clearParameters()
Clear the collection of parameters associated with this Request.
Specified by:
clearParameters in interface HttpRequest


createInputStream

public ServletInputStream createInputStream()
            throws IOException
Create and return a ServletInputStream to read the content associated with this Request.
Specified by:
createInputStream in interface Request


finishRequest

public void finishRequest()
            throws IOException
Perform whatever actions are required to flush and close the input stream or reader, in a single operation.
Specified by:
finishRequest in interface Request


getAttribute

public Object getAttribute(String name)


getAttributeNames

public Enumeration getAttributeNames()


getAuthType

public String getAuthType()


getAuthorization

public String getAuthorization()
Return the authorization credentials sent with this request.
Specified by:
getAuthorization in interface Request


getCharacterEncoding

public String getCharacterEncoding()


getConnector

public Connector getConnector()
Return the Connector through which this Request was received.
Specified by:
getConnector in interface Request


getContentLength

public int getContentLength()


getContentType

public String getContentType()


getContext

public Context getContext()
Return the Context within which this Request is being processed.
Specified by:
getContext in interface Request


getContextPath

public String getContextPath()


getContextPathMB

public MessageBytes getContextPathMB()
Get the context path.
Specified by:
getContextPathMB in interface HttpRequest

Returns:
the context path


getCookies

public Cookie[] getCookies()


getDateHeader

public long getDateHeader(String name)


getDecodedRequestURI

public String getDecodedRequestURI()
Get the decoded request URI.
Specified by:
getDecodedRequestURI in interface HttpRequest

Returns:
the URL decoded request URI


getDecodedRequestURIMB

public MessageBytes getDecodedRequestURIMB()
Get the decoded request URI.
Specified by:
getDecodedRequestURIMB in interface HttpRequest

Returns:
the URL decoded request URI


getFilterChain

public FilterChain getFilterChain()
Get filter chain associated with the request.
Specified by:
getFilterChain in interface Request


getHeader

public String getHeader(String name)


getHeaderNames

public Enumeration getHeaderNames()


getHeaders

public Enumeration getHeaders(String name)


getHost

public Host getHost()
Return the Host within which this Request is being processed.
Specified by:
getHost in interface Request


getInfo

public String getInfo()
Return descriptive information about this Request implementation and the corresponding version number, in the format <description>/<version>.
Specified by:
getInfo in interface Request


getInputStream

public ServletInputStream getInputStream()
            throws IOException


getIntHeader

public int getIntHeader(String name)


getLocalAddr

public String getLocalAddr()


getLocalName

public String getLocalName()


getLocalPort

public int getLocalPort()


getLocale

public Locale getLocale()


getLocales

public Enumeration getLocales()


getMethod

public String getMethod()


getNote

public Object getNote(String name)
Return the object bound with the specified name to the internal notes for this request, or null if no such binding exists.
Specified by:
getNote in interface Request

Parameters:
name - Name of the note to be returned


getNoteNames

public Iterator getNoteNames()
Return an Iterator containing the String names of all notes bindings that exist for this request.
Specified by:
getNoteNames in interface Request


getParameter

public String getParameter(String name)


getParameterMap

public Map getParameterMap()


getParameterNames

public Enumeration getParameterNames()


getParameterValues

public String[] getParameterValues(String name)


getPathInfo

public String getPathInfo()


getPathInfoMB

public MessageBytes getPathInfoMB()
Get the path info.
Specified by:
getPathInfoMB in interface HttpRequest

Returns:
the path info


getPathTranslated

public String getPathTranslated()


getProtocol

public String getProtocol()


getQueryString

public String getQueryString()


getReader

public BufferedReader getReader()
            throws IOException


getRealPath

public String getRealPath(String path)


getRemoteAddr

public String getRemoteAddr()


getRemoteHost

public String getRemoteHost()


getRemotePort

public int getRemotePort()


getRemoteUser

public String getRemoteUser()


getRequest

public ServletRequest getRequest()
Return the ServletRequest for which this object is the facade.
Specified by:
getRequest in interface Request


getRequestDispatcher

public RequestDispatcher getRequestDispatcher(String path)


getRequestPathMB

public MessageBytes getRequestPathMB()
Get the request path.
Specified by:
getRequestPathMB in interface HttpRequest

Returns:
the request path


getRequestURI

public String getRequestURI()


getRequestURL

public StringBuffer getRequestURL()


getRequestedSessionId

public String getRequestedSessionId()


getResponse

public Response getResponse()
Return the Response with which this Request is associated.
Specified by:
getResponse in interface Request


getScheme

public String getScheme()


getServerName

public String getServerName()


getServerPort

public int getServerPort()


getServletPath

public String getServletPath()


getServletPathMB

public MessageBytes getServletPathMB()
Get the servlet path.
Specified by:
getServletPathMB in interface HttpRequest

Returns:
the servlet path


getSession

public HttpSession getSession()


getSession

public HttpSession getSession(boolean create)


getSocket

public Socket getSocket()
Return the Socket (if any) through which this Request was received. This should only be used to access underlying state information about this Socket, such as the SSLSession associated with an SSLSocket.
Specified by:
getSocket in interface Request


getStream

public InputStream getStream()
Return the input stream associated with this Request.
Specified by:
getStream in interface Request


getUserPrincipal

public Principal getUserPrincipal()


getValveContext

public ValveContext getValveContext()
Get valve context.
Specified by:
getValveContext in interface Request


getWrapper

public Wrapper getWrapper()
Return the Wrapper within which this Request is being processed.
Specified by:
getWrapper in interface Request


isRequestedSessionIdFromCookie

public boolean isRequestedSessionIdFromCookie()


isRequestedSessionIdFromURL

public boolean isRequestedSessionIdFromURL()


isRequestedSessionIdFromUrl

public boolean isRequestedSessionIdFromUrl()


isRequestedSessionIdValid

public boolean isRequestedSessionIdValid()


isSecure

public boolean isSecure()


isUserInRole

public boolean isUserInRole(String role)


recycle

public void recycle()
Release all object references, and initialize instance variables, in preparation for reuse of this object.
Specified by:
recycle in interface Request


removeAttribute

public void removeAttribute(String name)


removeNote

public void removeNote(String name)
Remove any object bound to the specified name in the internal notes for this request.
Specified by:
removeNote in interface Request

Parameters:
name - Name of the note to be removed


setAttribute

public void setAttribute(String name,
                         Object value)


setAuthType

public void setAuthType(String authType)
Set the authentication type used for this request, if any; otherwise set the type to null. Typical values are "BASIC", "DIGEST", or "SSL".
Specified by:
setAuthType in interface HttpRequest

Parameters:


setAuthorization

public void setAuthorization(String authorization)
Set the authorization credentials sent with this request.
Specified by:
setAuthorization in interface Request

Parameters:
authorization - The new authorization credentials


setCharacterEncoding

public void setCharacterEncoding(String enc)
            throws UnsupportedEncodingException


setConnector

public void setConnector(Connector connector)
Set the Connector through which this Request was received.
Specified by:
setConnector in interface Request

Parameters:
connector - The new connector


setContentLength

public void setContentLength(int length)
Set the content length associated with this Request.
Specified by:
setContentLength in interface Request

Parameters:
length - The new content length


setContentType

public void setContentType(String type)
Set the content type (and optionally the character encoding) associated with this Request. For example, text/html; charset=ISO-8859-4.
Specified by:
setContentType in interface Request

Parameters:
type - The new content type


setContext

public void setContext(Context context)
Set the Context within which this Request is being processed. This must be called as soon as the appropriate Context is identified, because it identifies the value to be returned by getContextPath(), and thus enables parsing of the request URI.
Specified by:
setContext in interface Request

Parameters:
context - The newly associated Context


setContextPath

public void setContextPath(String path)
Set the context path for this Request. This will normally be called when the associated Context is mapping the Request to a particular Wrapper.
Specified by:
setContextPath in interface HttpRequest

Parameters:
path - The context path


setDecodedRequestURI

public void setDecodedRequestURI(String uri)
Set the decoded request URI.
Specified by:
setDecodedRequestURI in interface HttpRequest

Parameters:
uri - The decoded request URI


setFilterChain

public void setFilterChain(FilterChain filterChain)
Set filter chain associated with the request.
Specified by:
setFilterChain in interface Request

Parameters:
filterChain - new filter chain


setHost

public void setHost(Host host)
Set the Host within which this Request is being processed. This must be called as soon as the appropriate Host is identified, and before the Request is passed to a context.
Specified by:
setHost in interface Request

Parameters:
host - The newly associated Host


setMethod

public void setMethod(String method)
Set the HTTP request method used for this Request.
Specified by:
setMethod in interface HttpRequest

Parameters:
method - The request method


setNote

public void setNote(String name,
                    Object value)
Bind an object to a specified name in the internal notes associated with this request, replacing any existing binding for this name.
Specified by:
setNote in interface Request

Parameters:
name - Name to which the object should be bound
value - Object to be bound to the specified name


setPathInfo

public void setPathInfo(String path)
Set the path information for this Request. This will normally be called when the associated Context is mapping the Request to a particular Wrapper.
Specified by:
setPathInfo in interface HttpRequest

Parameters:
path - The path information


setProtocol

public void setProtocol(String protocol)
Set the protocol name and version associated with this Request.
Specified by:
setProtocol in interface Request

Parameters:
protocol - Protocol name and version


setQueryString

public void setQueryString(String query)
Set the query string for this Request. This will normally be called by the HTTP Connector, when it parses the request headers.
Specified by:
setQueryString in interface HttpRequest

Parameters:
query - The query string


setRemoteAddr

public void setRemoteAddr(String remoteAddr)
Set the remote IP address associated with this Request. NOTE: This value will be used to resolve the value for getRemoteHost() if that method is called.
Specified by:
setRemoteAddr in interface Request

Parameters:


setRemoteHost

public void setRemoteHost(String remoteHost)


setRequestURI

public void setRequestURI(String uri)
Set the unparsed request URI for this Request. This will normally be called by the HTTP Connector, when it parses the request headers.
Specified by:
setRequestURI in interface HttpRequest

Parameters:
uri - The request URI


setRequestedSessionCookie

public void setRequestedSessionCookie(boolean flag)
Set a flag indicating whether or not the requested session ID for this request came in through a cookie. This is normally called by the HTTP Connector, when it parses the request headers.
Specified by:
setRequestedSessionCookie in interface HttpRequest

Parameters:
flag - The new flag


setRequestedSessionId

public void setRequestedSessionId(String id)
Set the requested session ID for this request. This is normally called by the HTTP Connector, when it parses the request headers.
Specified by:
setRequestedSessionId in interface HttpRequest

Parameters:
id - The new session id


setRequestedSessionURL

public void setRequestedSessionURL(boolean flag)
Set a flag indicating whether or not the requested session ID for this request came in through a URL. This is normally called by the HTTP Connector, when it parses the request headers.
Specified by:
setRequestedSessionURL in interface HttpRequest

Parameters:
flag - The new flag


setResponse

public void setResponse(Response response)
Set the Response with which this Request is associated.
Specified by:
setResponse in interface Request

Parameters:
response - The new associated response


setScheme

public void setScheme(String scheme)
Set the name of the scheme associated with this request. Typical values are http, https, and ftp.
Specified by:
setScheme in interface Request

Parameters:
scheme - The scheme


setSecure

public void setSecure(boolean secure)
Set the value to be returned by isSecure() for this Request.
Specified by:
setSecure in interface Request

Parameters:
secure - The new isSecure value


setServerName

public void setServerName(String name)
Set the name of the server (virtual host) to process this request.
Specified by:
setServerName in interface Request

Parameters:
name - The server name


setServerPort

public void setServerPort(int port)
Set the port number of the server to process this request.
Specified by:
setServerPort in interface Request

Parameters:
port - The server port


setServletPath

public void setServletPath(String path)
Set the servlet path for this Request. This will normally be called when the associated Context is mapping the Request to a particular Wrapper.
Specified by:
setServletPath in interface HttpRequest

Parameters:
path - The servlet path


setSocket

public void setSocket(Socket socket)
Set the Socket (if any) through which this Request was received.
Specified by:
setSocket in interface Request

Parameters:
socket - The socket through which this request was received


setStream

public void setStream(InputStream input)
Set the input stream associated with this Request.
Specified by:
setStream in interface Request

Parameters:


setUserPrincipal

public void setUserPrincipal(Principal principal)
Set the Principal who has been authenticated for this Request. This value is also used to calculate the value to be returned by the getRemoteUser() method.
Specified by:
setUserPrincipal in interface HttpRequest

Parameters:
principal - The user Principal


setValveContext

public void setValveContext(ValveContext valveContext)
Set valve context.
Specified by:
setValveContext in interface Request

Parameters:
valveContext - New valve context object


setWrapper

public void setWrapper(Wrapper wrapper)
Set the Wrapper within which this Request is being processed. This must be called as soon as the appropriate Wrapper is identified, and before the Request is ultimately passed to an application servlet.
Specified by:
setWrapper in interface Request

Parameters:
wrapper - The newly associated Wrapper


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.