atg.servlet
Class MutableHttpServletRequest

java.lang.Object
  extended by atg.servlet.MutableHttpServletRequest
All Implemented Interfaces:
javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest
Direct Known Subclasses:
DynamoHttpServletRequest

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

This class is a wrapper around an HttpServletRequest that allows fields of the normally immutable request to be set.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
MutableHttpServletRequest()
          Constructs a new MutableHttpServletRequest
MutableHttpServletRequest(javax.servlet.http.HttpServletRequest pRequest)
          Constructs a new MutableHttpServletRequest
 
Method Summary
 java.lang.Object getAttribute(java.lang.String p0)
          Wraps the call to getAttribute
 java.lang.Object getAttribute(java.lang.String p0, boolean pCreate)
          Wraps the call to getAttribute
 java.util.Enumeration getAttributeNames()
          Returns an Enumeration containing the names of the attributes available to this request.
 java.lang.String getAuthType()
          Wraps the call to getAuthType
 java.lang.String getCharacterEncoding()
          Returns the character set encoding for the input of this request.
 int getContentLength()
          Wraps the call to getContentLength
 java.lang.String getContentType()
          Wraps the call to getContentType
 java.lang.String getContextPath()
          Returns the portion of the request URI that indicates the context of the request.
 javax.servlet.http.Cookie[] getCookies()
          Gets the array of cookies found in this request.
 long getDateHeader(java.lang.String p0)
          Wraps the call to getDateHeader
 java.lang.String getHeader(java.lang.String p0)
          Wraps the call to getHeader
 java.util.Enumeration getHeaderNames()
          Wraps the call to getHeaderNames
 java.util.Enumeration getHeaders(java.lang.String pName)
          Returns all the values of the specified request header as an Enumeration of String objects.
 javax.servlet.ServletInputStream getInputStream()
          Wraps the call to getInputStream
 int getIntHeader(java.lang.String p0)
          Wraps the call to getIntHeader
 java.lang.String getLocalAddr()
           
 java.util.Locale getLocale()
          Returns the preferred Locale that the client will accept content in, based purely 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.
 java.lang.String getLocalName()
           
 int getLocalPort()
           
 java.lang.String getMethod()
          Wraps the call to getMethod
 java.lang.String getParameter(java.lang.String p0)
          Wraps the call to getParameter
 java.util.Map getParameterMap()
          Returns a java.util.Map of the parameters of this request.
 java.util.Enumeration getParameterNames()
          Wraps the call to getParameterNames
 java.lang.String[] getParameterValues(java.lang.String p0)
          Wraps the call to getParameterValues
 java.lang.String getPathInfo()
          Wraps the call to getPathInfo
 java.lang.String getPathTranslated()
          Wraps the call to getPathTranslated
 java.lang.Object getPermanentAttribute(AttributeFactory pKey)
          This returns a permanent attribute value corresponding to the given key.
 java.lang.String getProtocol()
          Wraps the call to getProtocol
 java.lang.String getQueryString()
          Wraps the call to getQueryString
 java.io.BufferedReader getReader()
          Returns an input stream for reading the request body.
 java.lang.String getRealPath(java.lang.String p0)
          Wraps the call to getRealPath
 java.lang.String getRemoteAddr()
          Wraps the call to getRemoteAddr
 java.lang.String getRemoteHost()
          Wraps the call to getRemoteHost
 int getRemotePort()
           
 java.lang.String getRemoteUser()
          Wraps the call to getRemoteUser
 javax.servlet.http.HttpServletRequest getRequest()
          Returns the request embedded by this request.
 javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String pPath)
          Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.
 java.lang.String getRequestedSessionId()
          Gets the session id specified with this request.
 java.lang.String getRequestURI()
          Wraps the call to getRequestURI
 java.lang.StringBuffer getRequestURL()
          Reconstructs the URL the client used to make the request.
 java.lang.String getScheme()
          Wraps the call to getScheme
 java.lang.String getServerName()
          Wraps the call to getServerName
 int getServerPort()
          Wraps the call to getServerPort
 java.lang.String getServletPath()
          Wraps the call to getServletPath
 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 create)
          Gets the current valid session associated with this request, if create is false or, if necessary, creates a new session for the request, if create is true.
 java.security.Principal getUserPrincipal()
          Returns a java.security.Principal object containing the name of the current authenticated user.
 boolean isRequestedSessionIdFromCookie()
          Checks whether the session id specified by this request came in as a cookie.
 boolean isRequestedSessionIdFromUrl()
          Deprecated.  
 boolean isRequestedSessionIdFromURL()
          Checks whether the session id specified by this request came in as part of the URL.
 boolean isRequestedSessionIdValid()
          Checks whether this request is associated with a session that is valid in the current session context.
 boolean isSecure()
          Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS
 boolean isUserInRole(java.lang.String pRole)
           
 void removeAttribute(java.lang.String pName)
          Removes an attribute from this request.
 void setAttribute(java.lang.String pName, java.lang.Object pValue)
          Sets an attribute with the given name and value.
 void setAttributeFactory(java.lang.String pName, AttributeFactory pFactory)
          Sets an attribute factory that will only be called if someone asks for the specified attribute.
 void setAuthType(java.lang.String pAuthType)
          Sets the AuthType
 void setCharacterEncoding(java.lang.String pEncoding)
          Overrides the name of the character encoding used in the body of this request.
 void setContentLength(int pContentLength)
          Sets the ContentLength
 void setContentType(java.lang.String pContentType)
          Sets the ContentType
 void setContextPath(java.lang.String pContextPath)
          Sets the portion of the request URI that indicates the context of the request.
 void setInputStream(javax.servlet.ServletInputStream pInputStream)
          Sets the InputStream
 void setMethod(java.lang.String pMethod)
          Sets the Method
 void setPathInfo(java.lang.String pPathInfo)
          Sets the PathInfo
 void setPathTranslated(java.lang.String pPathTranslated)
          Sets the PathTranslated
 void setProtocol(java.lang.String pProtocol)
          Sets the Protocol
 void setQueryString(java.lang.String pQueryString)
          Sets the QueryString
 void setRemoteAddr(java.lang.String pRemoteAddr)
          Sets the RemoteAddr
 void setRemoteHost(java.lang.String pRemoteHost)
          Sets the RemoteHost
 void setRemoteUser(java.lang.String pRemoteUser)
          Sets the RemoteUser
 void setRequest(javax.servlet.http.HttpServletRequest pRequest)
          Sets the embedded request to be the given request.
 void setRequestURI(java.lang.String pRequestURI)
          Sets the RequestURI
 void setScheme(java.lang.String pScheme)
          Sets the Scheme
 void setServerName(java.lang.String pServerName)
          Sets the ServerName
 void setServerPort(int pServerPort)
          Sets the ServerPort
 void setServletPath(java.lang.String pServletPath)
          Sets the ServletPath
protected  void swapRequest(javax.servlet.http.HttpServletRequest pRequest)
          Swaps in a new underlying request object without doing a reset().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

MutableHttpServletRequest

public MutableHttpServletRequest()
Constructs a new MutableHttpServletRequest


MutableHttpServletRequest

public MutableHttpServletRequest(javax.servlet.http.HttpServletRequest pRequest)
Constructs a new MutableHttpServletRequest

Parameters:
pRequest - the request being wrapped
Method Detail

setRequest

public void setRequest(javax.servlet.http.HttpServletRequest pRequest)
Sets the embedded request to be the given request. This will also reset the object, clearing out any set or cached values. All attributes and attribute factories are also removed. Permanent attributes, however, are not removed.


swapRequest

protected void swapRequest(javax.servlet.http.HttpServletRequest pRequest)
Swaps in a new underlying request object without doing a reset().


getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Returns the request embedded by this request.


getContentLength

public int getContentLength()
Wraps the call to getContentLength

Specified by:
getContentLength in interface javax.servlet.ServletRequest

getContentType

public java.lang.String getContentType()
Wraps the call to getContentType

Specified by:
getContentType in interface javax.servlet.ServletRequest

getProtocol

public java.lang.String getProtocol()
Wraps the call to getProtocol

Specified by:
getProtocol in interface javax.servlet.ServletRequest

getScheme

public java.lang.String getScheme()
Wraps the call to getScheme

Specified by:
getScheme in interface javax.servlet.ServletRequest

getServerName

public java.lang.String getServerName()
Wraps the call to getServerName

Specified by:
getServerName in interface javax.servlet.ServletRequest

getServerPort

public int getServerPort()
Wraps the call to getServerPort

Specified by:
getServerPort in interface javax.servlet.ServletRequest

getRemoteAddr

public java.lang.String getRemoteAddr()
Wraps the call to getRemoteAddr

Specified by:
getRemoteAddr in interface javax.servlet.ServletRequest

getRemoteHost

public java.lang.String getRemoteHost()
Wraps the call to getRemoteHost

Specified by:
getRemoteHost in interface javax.servlet.ServletRequest

getRealPath

public java.lang.String getRealPath(java.lang.String p0)
Wraps the call to getRealPath

Specified by:
getRealPath in interface javax.servlet.ServletRequest

getInputStream

public javax.servlet.ServletInputStream getInputStream()
                                                throws java.io.IOException
Wraps the call to getInputStream

Specified by:
getInputStream in interface javax.servlet.ServletRequest
Throws:
java.io.IOException

getParameter

public java.lang.String getParameter(java.lang.String p0)
Wraps the call to getParameter

Specified by:
getParameter in interface javax.servlet.ServletRequest

getParameterValues

public java.lang.String[] getParameterValues(java.lang.String p0)
Wraps the call to getParameterValues

Specified by:
getParameterValues in interface javax.servlet.ServletRequest

getParameterNames

public java.util.Enumeration getParameterNames()
Wraps the call to getParameterNames

Specified by:
getParameterNames in interface javax.servlet.ServletRequest

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:
getParameterMap in interface javax.servlet.ServletRequest
Returns:
an immutable java.util.Map containing parameter names as keys and parameter values as map values. The keys in the parameter map are of type String. The values in the parameter map are of type String array.

getAttribute

public java.lang.Object getAttribute(java.lang.String p0)
Wraps the call to getAttribute

Specified by:
getAttribute in interface javax.servlet.ServletRequest

getAttribute

public java.lang.Object getAttribute(java.lang.String p0,
                                     boolean pCreate)
Wraps the call to getAttribute


getAttributeNames

public java.util.Enumeration getAttributeNames()
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.

Specified by:
getAttributeNames in interface javax.servlet.ServletRequest
Returns:
an Enumeration of strings containing the names of the request's attributes

getMethod

public java.lang.String getMethod()
Wraps the call to getMethod

Specified by:
getMethod in interface javax.servlet.http.HttpServletRequest

getRequestURI

public java.lang.String getRequestURI()
Wraps the call to getRequestURI

Specified by:
getRequestURI in interface javax.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:
getRequestURL in interface javax.servlet.http.HttpServletRequest
Returns:
a StringBuffer object containing the reconstructed URL

getServletPath

public java.lang.String getServletPath()
Wraps the call to getServletPath

Specified by:
getServletPath in interface javax.servlet.http.HttpServletRequest

getPathInfo

public java.lang.String getPathInfo()
Wraps the call to getPathInfo

Specified by:
getPathInfo in interface javax.servlet.http.HttpServletRequest

getPathTranslated

public java.lang.String getPathTranslated()
Wraps the call to getPathTranslated

Specified by:
getPathTranslated in interface javax.servlet.http.HttpServletRequest

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 "".

Specified by:
getContextPath in interface javax.servlet.http.HttpServletRequest
Returns:
String specifying the portion of the request URI that indicates the context of the request.

getQueryString

public java.lang.String getQueryString()
Wraps the call to getQueryString

Specified by:
getQueryString in interface javax.servlet.http.HttpServletRequest

getRemoteUser

public java.lang.String getRemoteUser()
Wraps the call to getRemoteUser

Specified by:
getRemoteUser in interface javax.servlet.http.HttpServletRequest

getAuthType

public java.lang.String getAuthType()
Wraps the call to getAuthType

Specified by:
getAuthType in interface javax.servlet.http.HttpServletRequest

getHeader

public java.lang.String getHeader(java.lang.String p0)
Wraps the call to getHeader

Specified by:
getHeader in interface javax.servlet.http.HttpServletRequest

getIntHeader

public int getIntHeader(java.lang.String p0)
Wraps the call to getIntHeader

Specified by:
getIntHeader in interface javax.servlet.http.HttpServletRequest

getDateHeader

public long getDateHeader(java.lang.String p0)
Wraps the call to getDateHeader

Specified by:
getDateHeader in interface javax.servlet.http.HttpServletRequest

getHeaderNames

public java.util.Enumeration getHeaderNames()
Wraps the call to getHeaderNames

Specified by:
getHeaderNames in interface javax.servlet.http.HttpServletRequest

getHeaders

public java.util.Enumeration getHeaders(java.lang.String pName)
Returns all the values of the specified request header as an Enumeration of String objects. Some headers, such as Accept-Language can be sent by clients as several headers each with a different value rather than sending the header as a comma separated list.

If the request did not include any headers of the specified name, this method returns an empty Enumeration. The header name is case insensitive. You can use this method with any request header.

Specified by:
getHeaders in interface javax.servlet.http.HttpServletRequest
Parameters:
pName - a String specifying the header name
Returns:
a Enumeration containing the values of the requested header, or an empty Enumeration if the request does not have any headers of that name.

setContentLength

public void setContentLength(int pContentLength)
Sets the ContentLength


setContentType

public void setContentType(java.lang.String pContentType)
Sets the ContentType


setProtocol

public void setProtocol(java.lang.String pProtocol)
Sets the Protocol


setScheme

public void setScheme(java.lang.String pScheme)
Sets the Scheme


setServerName

public void setServerName(java.lang.String pServerName)
Sets the ServerName


setServerPort

public void setServerPort(int pServerPort)
Sets the ServerPort


setRemoteAddr

public void setRemoteAddr(java.lang.String pRemoteAddr)
Sets the RemoteAddr


setRemoteHost

public void setRemoteHost(java.lang.String pRemoteHost)
Sets the RemoteHost


setInputStream

public void setInputStream(javax.servlet.ServletInputStream pInputStream)
Sets the InputStream


setMethod

public void setMethod(java.lang.String pMethod)
Sets the Method


setRequestURI

public void setRequestURI(java.lang.String pRequestURI)
Sets the RequestURI


setServletPath

public void setServletPath(java.lang.String pServletPath)
Sets the ServletPath


setPathInfo

public void setPathInfo(java.lang.String pPathInfo)
Sets the PathInfo


setPathTranslated

public void setPathTranslated(java.lang.String pPathTranslated)
Sets the PathTranslated


setQueryString

public void setQueryString(java.lang.String pQueryString)
Sets the QueryString


setRemoteUser

public void setRemoteUser(java.lang.String pRemoteUser)
Sets the RemoteUser


setAuthType

public void setAuthType(java.lang.String pAuthType)
Sets the AuthType


setContextPath

public void setContextPath(java.lang.String pContextPath)
Sets 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 "".


getPermanentAttribute

public java.lang.Object getPermanentAttribute(AttributeFactory pKey)
This returns a permanent attribute value corresponding to the given key. If the key is not found in the list of permanent attributes, then it will be called to generate the value, and the key will from then on be associated with the value.


setAttribute

public void setAttribute(java.lang.String pName,
                         java.lang.Object pValue)
Sets an attribute with the given name and value. Overwrites the value of any attribute with the same name.

Specified by:
setAttribute in interface javax.servlet.ServletRequest

removeAttribute

public void removeAttribute(java.lang.String pName)
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.*, and com.sun.*, are reserved for use by Sun Microsystems.

Specified by:
removeAttribute in interface javax.servlet.ServletRequest
Parameters:
pName - a String specifying the name of the attribute to remove

setAttributeFactory

public void setAttributeFactory(java.lang.String pName,
                                AttributeFactory pFactory)
Sets an attribute factory that will only be called if someone asks for the specified attribute.


getCookies

public javax.servlet.http.Cookie[] getCookies()
Gets the array of cookies found in this request.

Specified by:
getCookies in interface javax.servlet.http.HttpServletRequest
Returns:
the array of cookies found in this request

getSession

public javax.servlet.http.HttpSession getSession(boolean create)
Gets the current valid session associated with this request, if create is false or, if necessary, creates a new session for the request, if create is true.

Note: to ensure the session is properly maintained, the servlet developer must call this method (at least once) before any output is written to the response.

Additionally, application-writers need to be aware that newly created sessions (that is, sessions for which HttpSession.isNew returns true) do not have any application-specific state.

Specified by:
getSession in interface javax.servlet.http.HttpServletRequest
Returns:
the session associated with this request or null if create was false and no valid session is associated with this request.

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:
getSession in interface javax.servlet.http.HttpServletRequest
Returns:
the HttpSession associated with this request

getRequestedSessionId

public java.lang.String getRequestedSessionId()
Gets the session id specified with this request. This may differ from the actual session id. For example, if the request specified an id for an invalid session, then this will get a new session with a new id.

Specified by:
getRequestedSessionId in interface javax.servlet.http.HttpServletRequest
Returns:
the session id specified by this request, or null if the request did not specify a session id
See Also:
isRequestedSessionIdValid()

isRequestedSessionIdValid

public boolean isRequestedSessionIdValid()
Checks whether this request is associated with a session that is valid in the current session context. If it is not valid, the requested session will never be returned from the getSession method.

Specified by:
isRequestedSessionIdValid in interface javax.servlet.http.HttpServletRequest
Returns:
true if this request is assocated with a session that is valid in the current session context.
See Also:
getRequestedSessionId(), HttpSessionContext, getSession(boolean)

isRequestedSessionIdFromCookie

public boolean isRequestedSessionIdFromCookie()
Checks whether the session id specified by this request came in as a cookie. (The requested session may not be one returned by the getSession method.)

Specified by:
isRequestedSessionIdFromCookie in interface javax.servlet.http.HttpServletRequest
Returns:
true if the session id specified by this request came in as a cookie; false otherwise
See Also:
getSession(boolean)

isRequestedSessionIdFromUrl

public boolean isRequestedSessionIdFromUrl()
Deprecated. 

Checks whether the session id specified by this request came in as part of the URL. (The requested session may not be the one returned by the getSession method.)

Specified by:
isRequestedSessionIdFromUrl in interface javax.servlet.http.HttpServletRequest
Returns:
true if the session id specified by the request for this session came in as part of the URL; false otherwise
See Also:
getSession(boolean), isRequestedSessionIdFromURL()

isRequestedSessionIdFromURL

public boolean isRequestedSessionIdFromURL()
Checks whether the session id specified by this request came in as part of the URL. (The requested session may not be the one returned by the getSession method.)

Specified by:
isRequestedSessionIdFromURL in interface javax.servlet.http.HttpServletRequest
Returns:
true if the session id specified by the request for this session came in as part of the URL; false otherwise
See Also:
getSession(boolean)

getReader

public java.io.BufferedReader getReader()
                                 throws java.io.IOException
Returns an input stream for reading the request body.

Specified by:
getReader in interface javax.servlet.ServletRequest
Throws:
java.io.IOException

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Returns the character set encoding for the input of this request.

Specified by:
getCharacterEncoding in interface javax.servlet.ServletRequest

setCharacterEncoding

public void setCharacterEncoding(java.lang.String pEncoding)
                          throws java.io.UnsupportedEncodingException
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().

Specified by:
setCharacterEncoding in interface javax.servlet.ServletRequest
Parameters:
a - String containing the name of the chararacter encoding.
Throws:
java.io.UnsupportedEncodingException - if this is not a valid encoding

isUserInRole

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

getUserPrincipal

public java.security.Principal getUserPrincipal()
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.

Specified by:
getUserPrincipal in interface javax.servlet.http.HttpServletRequest
Returns:
a java.security.Principal containing the name of the user making this request; null if the user has not been authenticated

isSecure

public boolean isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS

Specified by:
isSecure in interface javax.servlet.ServletRequest
Returns:
a boolean indicating if the request was made using a secure channel

getLocale

public java.util.Locale getLocale()
Returns the preferred Locale that the client will accept content in, based purely on the Accept-Language header.

Specified by:
getLocale in interface javax.servlet.ServletRequest
Returns:
the preferred Locale for the client.

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.

Specified by:
getLocales in interface javax.servlet.ServletRequest
Returns:
an Enumeration of preferred Locale objects for the client

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String pPath)
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.

Specified by:
getRequestDispatcher in interface javax.servlet.ServletRequest
Parameters:
pPath - a String specifying the pathname to the resource
Returns:
a RequestDispatcher object that acts as a wrapper for the resource at the specified path.

getLocalAddr

public java.lang.String getLocalAddr()
Specified by:
getLocalAddr in interface javax.servlet.ServletRequest

getLocalName

public java.lang.String getLocalName()
Specified by:
getLocalName in interface javax.servlet.ServletRequest

getLocalPort

public int getLocalPort()
Specified by:
getLocalPort in interface javax.servlet.ServletRequest

getRemotePort

public int getRemotePort()
Specified by:
getRemotePort in interface javax.servlet.ServletRequest