org.apache.cactus.server
Class AbstractHttpServletRequestWrapper

java.lang.Object
  extended byorg.apache.cactus.server.AbstractHttpServletRequestWrapper
All Implemented Interfaces:
javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest
Direct Known Subclasses:
HttpServletRequestWrapper

public abstract class AbstractHttpServletRequestWrapper
extends java.lang.Object
implements javax.servlet.http.HttpServletRequest

Abstract wrapper around HttpServletRequest. This class provides a common implementation of the wrapper for the different servlet API.

Version:
$Id: AbstractHttpServletRequestWrapper.java,v 1.18 2003/06/16 16:41:11 cmlenz Exp $
Author:
Vincent Massol

Field Summary
protected  java.lang.String remoteHostName
          Remote Host name to simulate (if any)
protected  java.lang.String remoteIPAddress
          Remote IP address to simulate (if any)
protected  java.lang.String remoteUser
          Remote user to simulate (if any)
protected  javax.servlet.http.HttpServletRequest request
          The real HTTP request
protected  ServletURL url
          The URL to simulate
 
Constructor Summary
AbstractHttpServletRequestWrapper(javax.servlet.http.HttpServletRequest theRequest, ServletURL theURL)
          Construct an HttpServletRequest instance that delegates it's method calls to the request object passed as parameter and that uses the URL passed as parameter to simulate a URL from which the request would come from.
 
Method Summary
 java.lang.Object getAttribute(java.lang.String theName)
           
 java.util.Enumeration getAttributeNames()
           
 java.lang.String getAuthType()
           
 java.lang.String getCharacterEncoding()
           
 int getContentLength()
           
 java.lang.String getContentType()
           
 java.lang.String getContextPath()
           
 javax.servlet.http.Cookie[] getCookies()
           
 long getDateHeader(java.lang.String theName)
           
 java.lang.String getHeader(java.lang.String theName)
           
 java.util.Enumeration getHeaderNames()
           
 java.util.Enumeration getHeaders(java.lang.String theName)
           
 javax.servlet.ServletInputStream getInputStream()
           
 int getIntHeader(java.lang.String theName)
           
 java.util.Locale getLocale()
           
 java.util.Enumeration getLocales()
           
 java.lang.String getMethod()
           
 javax.servlet.http.HttpServletRequest getOriginalRequest()
           
 java.lang.String getParameter(java.lang.String theName)
           
 java.util.Enumeration getParameterNames()
           
 java.lang.String[] getParameterValues(java.lang.String theName)
           
 java.lang.String getPathInfo()
           
 java.lang.String getPathTranslated()
           
 java.lang.String getProtocol()
           
 java.lang.String getQueryString()
           
 java.io.BufferedReader getReader()
           
 java.lang.String getRealPath(java.lang.String thePath)
           
 java.lang.String getRemoteAddr()
           
 java.lang.String getRemoteHost()
           
 java.lang.String getRemoteUser()
           
 javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String thePath)
           
 java.lang.String getRequestedSessionId()
           
 java.lang.String getRequestURI()
           
 java.lang.String getScheme()
           
 java.lang.String getServerName()
           
 int getServerPort()
           
 java.lang.String getServletPath()
           
 javax.servlet.http.HttpSession getSession()
           
 javax.servlet.http.HttpSession getSession(boolean isCreate)
           
 java.security.Principal getUserPrincipal()
           
 boolean isRequestedSessionIdFromCookie()
           
 boolean isRequestedSessionIdFromUrl()
           
 boolean isRequestedSessionIdFromURL()
           
 boolean isRequestedSessionIdValid()
           
 boolean isSecure()
           
 boolean isUserInRole(java.lang.String theRole)
           
 void removeAttribute(java.lang.String theName)
           
 void setAttribute(java.lang.String theName, java.lang.Object theAttribute)
           
 void setRemoteHostName(java.lang.String theRemoteHostName)
          Simulates the remote host name(ie the client host name).
 void setRemoteIPAddress(java.lang.String theRemoteIPAddress)
          Simulates the remote IP address (ie the client IP address).
 void setRemoteUser(java.lang.String theRemoteUser)
          Sets the remote user name to simulate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

request

protected javax.servlet.http.HttpServletRequest request
The real HTTP request


url

protected ServletURL url
The URL to simulate


remoteIPAddress

protected java.lang.String remoteIPAddress
Remote IP address to simulate (if any)

See Also:
setRemoteIPAddress(String)

remoteHostName

protected java.lang.String remoteHostName
Remote Host name to simulate (if any)

See Also:
setRemoteHostName(String)

remoteUser

protected java.lang.String remoteUser
Remote user to simulate (if any)

See Also:
setRemoteUser(String)
Constructor Detail

AbstractHttpServletRequestWrapper

public AbstractHttpServletRequestWrapper(javax.servlet.http.HttpServletRequest theRequest,
                                         ServletURL theURL)
Construct an HttpServletRequest instance that delegates it's method calls to the request object passed as parameter and that uses the URL passed as parameter to simulate a URL from which the request would come from.

Parameters:
theRequest - the real HTTP request
theURL - the URL to simulate or null if none
Method Detail

getOriginalRequest

public javax.servlet.http.HttpServletRequest getOriginalRequest()
Returns:
the original request object

setRemoteIPAddress

public void setRemoteIPAddress(java.lang.String theRemoteIPAddress)
Simulates the remote IP address (ie the client IP address).

Parameters:
theRemoteIPAddress - the simulated IP address in string format. Exemple : "127.0.0.1"

setRemoteHostName

public void setRemoteHostName(java.lang.String theRemoteHostName)
Simulates the remote host name(ie the client host name).

Parameters:
theRemoteHostName - the simulated host name in string format. Exemple : "atlantis"

setRemoteUser

public void setRemoteUser(java.lang.String theRemoteUser)
Sets the remote user name to simulate.

Parameters:
theRemoteUser - the simulated remote user name

getContextPath

public java.lang.String getContextPath()
Specified by:
getContextPath in interface javax.servlet.http.HttpServletRequest
Returns:
the context path from the simulated URL or the real context path if a simulation URL has not been defined. The real context path will be returned if the context path defined in the simulated URL has a null value.

getPathInfo

public java.lang.String getPathInfo()
Specified by:
getPathInfo in interface javax.servlet.http.HttpServletRequest
Returns:
the path info from the simulated URL or the real path info if a simulation URL has not been defined.

getServerName

public java.lang.String getServerName()
Specified by:
getServerName in interface javax.servlet.ServletRequest
Returns:
the server name from the simulated URL or the real server name if a simulation URL has not been defined. If the server name defined in the simulation URL is null, return the real server name.

getServerPort

public int getServerPort()
Specified by:
getServerPort in interface javax.servlet.ServletRequest
Returns:
the server port number from the simulated URL or the real server port number if a simulation URL has not been defined. If no port is defined in the simulation URL, then port 80 is returned. If the server name has been defined with a null value in in the simulation URL, return the real server port.

getRequestURI

public java.lang.String getRequestURI()
Specified by:
getRequestURI in interface javax.servlet.http.HttpServletRequest
Returns:
the URI from the simulated URL or the real URI if a simulation URL has not been defined.

getServletPath

public java.lang.String getServletPath()
Specified by:
getServletPath in interface javax.servlet.http.HttpServletRequest
Returns:
the servlet path from the simulated URL or the real servlet path if a simulation URL has not been defined. The real servlet path will be returned if the servlet path defined in the simulated URL has a null value.

getPathTranslated

public java.lang.String getPathTranslated()
Specified by:
getPathTranslated in interface javax.servlet.http.HttpServletRequest
Returns:
any extra path information after the servlet name but before the query string, and translates it to a real path. Takes into account the simulated URL (if any).

getQueryString

public java.lang.String getQueryString()
Specified by:
getQueryString in interface javax.servlet.http.HttpServletRequest
Returns:
the query string from the simulated URL or the real query string if a simulation URL has not been defined.

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String thePath)
Specified by:
getRequestDispatcher in interface javax.servlet.ServletRequest
Parameters:
thePath - the path to the resource
Returns:
a wrapped request dispatcher instead of the real one, so that forward() and include() calls will use the wrapped dispatcher passing it the *original* request [this is needed for some servlet engine like Tomcat 3.x which do not support the new mechanism introduced by Servlet 2.3 Filters].
See Also:
ServletRequest.getRequestDispatcher(String)

getRemoteAddr

public java.lang.String getRemoteAddr()
Specified by:
getRemoteAddr in interface javax.servlet.ServletRequest
Returns:
the simulated remote IP address if any or the real one.
See Also:
ServletRequest.getRemoteAddr()

getRemoteHost

public java.lang.String getRemoteHost()
Specified by:
getRemoteHost in interface javax.servlet.ServletRequest
Returns:
the simulated remote host name if any or the real one.
See Also:
ServletRequest.getRemoteHost()

getRemoteUser

public java.lang.String getRemoteUser()
Specified by:
getRemoteUser in interface javax.servlet.http.HttpServletRequest
Returns:
the simulated remote user name if any or the real one.
See Also:
HttpServletRequest.getRemoteUser()

isRequestedSessionIdFromURL

public boolean isRequestedSessionIdFromURL()
Specified by:
isRequestedSessionIdFromURL in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.isRequestedSessionIdFromURL()

isRequestedSessionIdFromUrl

public boolean isRequestedSessionIdFromUrl()
Specified by:
isRequestedSessionIdFromUrl in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.isRequestedSessionIdFromUrl()

isUserInRole

public boolean isUserInRole(java.lang.String theRole)
Specified by:
isUserInRole in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.isUserInRole(String)

isRequestedSessionIdValid

public boolean isRequestedSessionIdValid()
Specified by:
isRequestedSessionIdValid in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.isRequestedSessionIdValid()

isRequestedSessionIdFromCookie

public boolean isRequestedSessionIdFromCookie()
Specified by:
isRequestedSessionIdFromCookie in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.isRequestedSessionIdFromCookie()

getLocales

public java.util.Enumeration getLocales()
Specified by:
getLocales in interface javax.servlet.ServletRequest
See Also:
ServletRequest.getLocales()

getHeader

public java.lang.String getHeader(java.lang.String theName)
Specified by:
getHeader in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.getHeader(String)

getHeaders

public java.util.Enumeration getHeaders(java.lang.String theName)
Specified by:
getHeaders in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.getHeaders(String)

getHeaderNames

public java.util.Enumeration getHeaderNames()
Specified by:
getHeaderNames in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.getHeaderNames()

getScheme

public java.lang.String getScheme()
Specified by:
getScheme in interface javax.servlet.ServletRequest
See Also:
ServletRequest.getScheme()

getAuthType

public java.lang.String getAuthType()
Specified by:
getAuthType in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.getAuthType()

getRealPath

public java.lang.String getRealPath(java.lang.String thePath)
Specified by:
getRealPath in interface javax.servlet.ServletRequest
See Also:
ServletRequest.getRealPath(String)

getSession

public javax.servlet.http.HttpSession getSession()
Specified by:
getSession in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.getSession()

getSession

public javax.servlet.http.HttpSession getSession(boolean isCreate)
Specified by:
getSession in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.getSession(boolean)

getReader

public java.io.BufferedReader getReader()
                                 throws java.io.IOException
Specified by:
getReader in interface javax.servlet.ServletRequest
Throws:
java.io.IOException
See Also:
ServletRequest.getReader()

getContentLength

public int getContentLength()
Specified by:
getContentLength in interface javax.servlet.ServletRequest
See Also:
ServletRequest.getContentLength()

getParameterValues

public java.lang.String[] getParameterValues(java.lang.String theName)
Specified by:
getParameterValues in interface javax.servlet.ServletRequest
See Also:
ServletRequest.getParameterValues(String)

getContentType

public java.lang.String getContentType()
Specified by:
getContentType in interface javax.servlet.ServletRequest
See Also:
ServletRequest.getContentType()

getLocale

public java.util.Locale getLocale()
Specified by:
getLocale in interface javax.servlet.ServletRequest
See Also:
ServletRequest.getLocale()

removeAttribute

public void removeAttribute(java.lang.String theName)
Specified by:
removeAttribute in interface javax.servlet.ServletRequest
See Also:
ServletRequest.removeAttribute(String)

getParameter

public java.lang.String getParameter(java.lang.String theName)
Specified by:
getParameter in interface javax.servlet.ServletRequest
See Also:
ServletRequest.getParameter(String)

getInputStream

public javax.servlet.ServletInputStream getInputStream()
                                                throws java.io.IOException
Specified by:
getInputStream in interface javax.servlet.ServletRequest
Throws:
java.io.IOException
See Also:
ServletRequest.getInputStream()

getUserPrincipal

public java.security.Principal getUserPrincipal()
Specified by:
getUserPrincipal in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.getUserPrincipal()

isSecure

public boolean isSecure()
Specified by:
isSecure in interface javax.servlet.ServletRequest
See Also:
ServletRequest.isSecure()

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Specified by:
getCharacterEncoding in interface javax.servlet.ServletRequest
See Also:
ServletRequest.getCharacterEncoding()

getParameterNames

public java.util.Enumeration getParameterNames()
Specified by:
getParameterNames in interface javax.servlet.ServletRequest
See Also:
ServletRequest.getParameterNames()

getMethod

public java.lang.String getMethod()
Specified by:
getMethod in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.getMethod()

setAttribute

public void setAttribute(java.lang.String theName,
                         java.lang.Object theAttribute)
Specified by:
setAttribute in interface javax.servlet.ServletRequest
See Also:
ServletRequest.setAttribute(String, Object)

getAttribute

public java.lang.Object getAttribute(java.lang.String theName)
Specified by:
getAttribute in interface javax.servlet.ServletRequest
See Also:
ServletRequest.getAttribute(String)

getIntHeader

public int getIntHeader(java.lang.String theName)
Specified by:
getIntHeader in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.getIntHeader(String)

getDateHeader

public long getDateHeader(java.lang.String theName)
Specified by:
getDateHeader in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.getDateHeader(String)

getAttributeNames

public java.util.Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface javax.servlet.ServletRequest
See Also:
ServletRequest.getAttributeNames()

getRequestedSessionId

public java.lang.String getRequestedSessionId()
Specified by:
getRequestedSessionId in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.getRequestedSessionId()

getCookies

public javax.servlet.http.Cookie[] getCookies()
Specified by:
getCookies in interface javax.servlet.http.HttpServletRequest
See Also:
HttpServletRequest.getCookies()

getProtocol

public java.lang.String getProtocol()
Specified by:
getProtocol in interface javax.servlet.ServletRequest
See Also:
ServletRequest.getProtocol()


Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.