org.apache.tomcat.core
Class RequestImpl

java.lang.Object
  |
  +--org.apache.tomcat.core.RequestImpl

public class RequestImpl
extends java.lang.Object
implements Request

Author:
James Duncan Davidson [duncan@eng.sun.com], James Todd [gonzo@eng.sun.com], Jason Hunter [jch@eng.sun.com], Harish Prabandham, Alex Cruikshank [alex@epitonic.com], Hans Bergsten [hans@gefionsoftware.com]

Field Summary
static int ACC_IN_OUT
           
static int ACC_OUT_COUNT
           
static int ACC_POST_MAP
           
static int ACC_POST_SERVICE
           
static int ACC_PRE_CMAP
           
static int ACC_PRE_RMAP
           
static int ACC_PRE_SERVICE
           
static int ACCOUNTS
           
protected  java.util.Hashtable attributes
           
protected  java.lang.String authType
           
protected  org.apache.tomcat.util.ByteBuffer bBuffer
           
protected  java.lang.String charEncoding
           
protected  int contentLength
           
protected  java.lang.String contentType
           
protected  Context context
           
protected  ContextManager contextM
           
protected  java.lang.String contextPath
           
protected  java.util.Vector cookies
           
protected  boolean didCookies
           
protected  boolean didParameters
           
protected  boolean didReadFormData
           
protected  ServletWrapper handler
           
protected  org.apache.tomcat.util.MimeHeaders headers
           
protected  javax.servlet.ServletInputStream in
           
protected  java.lang.String jvmRoute
           
protected  java.lang.String localHost
           
protected  java.lang.String lookupPath
           
protected  java.lang.String mappedPath
           
protected  java.lang.String method
           
protected  java.util.Hashtable parameters
           
protected  java.lang.String pathInfo
           
protected  java.lang.String pathTranslated
           
protected  boolean pathTranslatedIsSet
           
protected  java.security.Principal principal
           
protected  java.lang.String protocol
           
protected  java.lang.String queryString
           
protected  java.lang.String remoteAddr
           
protected  java.lang.String remoteHost
           
protected  java.lang.String remoteUser
           
protected  java.lang.String[] reqRoles
           
protected  java.lang.String reqSessionId
           
protected  javax.servlet.http.HttpServletRequest requestFacade
           
protected  java.lang.String requestURI
           
protected  Response response
           
protected  java.lang.String scheme
           
protected  java.lang.String serverName
           
protected  int serverPort
           
protected  javax.servlet.http.HttpSession serverSession
           
protected  java.lang.String servletName
           
protected  java.lang.String servletPath
           
protected  java.lang.String sessionIdSource
           
protected static org.apache.tomcat.util.StringManager sm
           
protected  java.lang.String[] userRoles
           
 
Fields inherited from interface org.apache.tomcat.core.Request
MAX_INCLUDE, SESSIONID_FROM_COOKIE, SESSIONID_FROM_URL
 
Constructor Summary
RequestImpl()
           
 
Method Summary
 int doRead()
           
 int doRead(byte[] b, int off, int len)
          Fill in the buffer.
 long getAccount(int pos)
           
 java.lang.Object getAttribute(java.lang.String name)
           
 java.util.Enumeration getAttributeNames()
           
 java.lang.String getAuthType()
           
 java.lang.String getCharacterEncoding()
           
 Request getChild()
          During include, a sub-request will be created.
 Container getContainer()
           
 int getContentLength()
           
 java.lang.String getContentType()
           
 Context getContext()
           
 ContextManager getContextManager()
           
 javax.servlet.http.Cookie getCookie(int idx)
           
 int getCookieCount()
           
 javax.servlet.http.Cookie[] getCookies()
           
 javax.servlet.http.HttpServletRequest getFacade()
          One-to-One with Facade
 java.lang.String getHeader(java.lang.String name)
           
 java.util.Enumeration getHeaderNames()
           
 java.util.Enumeration getHeaders(java.lang.String name)
           
 org.apache.tomcat.util.ByteBuffer getInputBuffer()
           
 javax.servlet.ServletInputStream getInputStream()
           
 java.lang.String getJvmRoute()
           
 java.lang.String getLocalHost()
           
 java.lang.String getLookupPath()
           
 java.lang.String getMappedPath()
          The file - result of mapping the request ( using aliases and other mapping rules.
 java.lang.String getMethod()
           
 org.apache.tomcat.util.MimeHeaders getMimeHeaders()
           
 java.lang.Object getNote(int pos)
           
 java.lang.String getParameter(java.lang.String name)
           
 java.util.Enumeration getParameterNames()
           
 java.util.Hashtable getParameters()
           
 java.lang.String[] getParameterValues(java.lang.String name)
          Set query string - will be called by forward
 Request getParent()
          If this is a sub-request, return the parent
 java.lang.String getPathInfo()
          Path Info - set be mappers or from adapter
 java.lang.String getPathTranslated()
          Not so usefull - it return the path translated for a URL relative the the context, i.e.
 java.lang.String getProtocol()
           
 java.lang.String getQueryString()
           
 java.io.BufferedReader getReader()
           
 java.lang.String getRemoteAddr()
           
 java.lang.String getRemoteHost()
          Expensive - should be implemented as a callback where possible!
 java.lang.String getRemoteUser()
           
 java.lang.String getRequestedSessionId()
           
 java.lang.String getRequestURI()
           
 java.lang.String[] getRequiredRoles()
          If this request is subject to a security constraint.
 Response getResponse()
          One-to-One with Response
 java.lang.String getScheme()
           
 java.lang.String getServerName()
          Return the server name.
 int getServerPort()
           
 java.lang.String getServletPath()
           
 java.lang.String getServletPrefix()
           
 javax.servlet.http.HttpSession getSession(boolean create)
           
 java.lang.String getSessionIdSource()
          Get the source of the session Id.
 Request getTop()
          This is the top request ( for a sub-request )
 java.security.Principal getUserPrincipal()
          Return the principal - the adapter will set it
 java.lang.String[] getUserRoles()
           
 ServletWrapper getWrapper()
          Wrapper - the servlet that will execute the request Similar with "handler" in Apache.
 boolean isSecure()
           
 boolean isUserInRole(java.lang.String role)
           
 void recycle()
          Support for "pools"
 void removeAttribute(java.lang.String name)
           
 void setAccount(int pos, long value)
           
 void setAttribute(java.lang.String name, java.lang.Object value)
           
 void setAuthType(java.lang.String authType)
           
 void setBody(java.lang.StringBuffer body)
           
 void setCharEncoding(java.lang.String enc)
           
 void setChild(Request req)
           
 void setContainer(Container container)
           
 void setContentLength(int len)
           
 void setContentType(java.lang.String type)
           
 void setContext(Context context)
          Context - will be set by contextMap stage of request interceptors
 void setContextManager(ContextManager cm)
          Pointer to the server engine - for errors, etc
 void setInputBuffer(org.apache.tomcat.util.ByteBuffer buf)
           
 void setJvmRoute(java.lang.String jvmRoute)
           
 void setLocalHost(java.lang.String host)
           
 void setLookupPath(java.lang.String l)
           
 void setMappedPath(java.lang.String m)
           
 void setMethod(java.lang.String method)
           
 void setMimeHeaders(org.apache.tomcat.util.MimeHeaders headers)
           
 void setNote(int pos, java.lang.Object value)
          Add a per/request internal attribute.
 void setParameters(java.util.Hashtable h)
           
 void setParent(Request req)
           
 void setPathInfo(java.lang.String pathInfo)
           
 void setPathTranslated(java.lang.String s)
          All adapters that know the PT needs to call this method, in order to set pathTranslatedIsSet, otherwise tomcat will try to compute it again
 void setProtocol(java.lang.String protocol)
           
 void setQueryString(java.lang.String queryString)
          Set query string - will be called by forward
 void setRemoteAddr(java.lang.String remoteAddr)
           
 void setRemoteHost(java.lang.String remoteHost)
           
 void setRemoteUser(java.lang.String s)
           
 void setRequestedSessionId(java.lang.String reqSessionId)
           
 void setRequestURI(java.lang.String r)
           
 void setRequiredRoles(java.lang.String[] roles)
           
 void setResponse(Response response)
           
 void setScheme(java.lang.String scheme)
           
 void setServerName(java.lang.String serverName)
          Virtual host
 void setServerPort(int serverPort)
           
 void setServletPath(java.lang.String servletPath)
          Servlet Path
 void setSession(javax.servlet.http.HttpSession serverSession)
           
 void setSessionIdSource(java.lang.String s)
           
 void setUserPrincipal(java.security.Principal p)
           
 void setUserRoles(java.lang.String[] roles)
           
 void setWrapper(ServletWrapper handler)
           
 java.lang.String toString()
           
 java.lang.String toStringDebug()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

jvmRoute

protected java.lang.String jvmRoute

requestURI

protected java.lang.String requestURI

queryString

protected java.lang.String queryString

serverName

protected java.lang.String serverName

cookies

protected java.util.Vector cookies

contextPath

protected java.lang.String contextPath

lookupPath

protected java.lang.String lookupPath

servletPath

protected java.lang.String servletPath

pathInfo

protected java.lang.String pathInfo

pathTranslated

protected java.lang.String pathTranslated

pathTranslatedIsSet

protected boolean pathTranslatedIsSet

parameters

protected java.util.Hashtable parameters

contentLength

protected int contentLength

contentType

protected java.lang.String contentType

charEncoding

protected java.lang.String charEncoding

authType

protected java.lang.String authType

remoteUser

protected java.lang.String remoteUser

principal

protected java.security.Principal principal

userRoles

protected java.lang.String[] userRoles

reqRoles

protected java.lang.String[] reqRoles

response

protected Response response

requestFacade

protected javax.servlet.http.HttpServletRequest requestFacade

context

protected Context context

contextM

protected ContextManager contextM

attributes

protected java.util.Hashtable attributes

didReadFormData

protected boolean didReadFormData

didParameters

protected boolean didParameters

didCookies

protected boolean didCookies

reqSessionId

protected java.lang.String reqSessionId

sessionIdSource

protected java.lang.String sessionIdSource

serverSession

protected javax.servlet.http.HttpSession serverSession

servletName

protected java.lang.String servletName

handler

protected ServletWrapper handler

mappedPath

protected java.lang.String mappedPath

scheme

protected java.lang.String scheme

method

protected java.lang.String method

protocol

protected java.lang.String protocol

headers

protected org.apache.tomcat.util.MimeHeaders headers

in

protected javax.servlet.ServletInputStream in

serverPort

protected int serverPort

remoteAddr

protected java.lang.String remoteAddr

remoteHost

protected java.lang.String remoteHost

localHost

protected java.lang.String localHost

bBuffer

protected org.apache.tomcat.util.ByteBuffer bBuffer

sm

protected static org.apache.tomcat.util.StringManager sm

ACC_PRE_CMAP

public static final int ACC_PRE_CMAP

ACC_PRE_RMAP

public static final int ACC_PRE_RMAP

ACC_POST_MAP

public static final int ACC_POST_MAP

ACC_PRE_SERVICE

public static final int ACC_PRE_SERVICE

ACC_POST_SERVICE

public static final int ACC_POST_SERVICE

ACC_IN_OUT

public static final int ACC_IN_OUT

ACC_OUT_COUNT

public static final int ACC_OUT_COUNT

ACCOUNTS

public static final int ACCOUNTS
Constructor Detail

RequestImpl

public RequestImpl()
Method Detail

setContext

public void setContext(Context context)
Description copied from interface: Request
Context - will be set by contextMap stage of request interceptors
Specified by:
setContext in interface Request

setContextManager

public void setContextManager(ContextManager cm)
Description copied from interface: Request
Pointer to the server engine - for errors, etc
Specified by:
setContextManager in interface Request

getContextManager

public ContextManager getContextManager()
Specified by:
getContextManager in interface Request

getScheme

public java.lang.String getScheme()
Specified by:
getScheme in interface Request

getMethod

public java.lang.String getMethod()
Specified by:
getMethod in interface Request

getRequestURI

public java.lang.String getRequestURI()
Specified by:
getRequestURI in interface Request

getQueryString

public java.lang.String getQueryString()
Specified by:
getQueryString in interface Request

getProtocol

public java.lang.String getProtocol()
Specified by:
getProtocol in interface Request

getServerName

public java.lang.String getServerName()
Return the server name. If none was set, extract it from the host header.
Specified by:
getServerName in interface Request

setServerName

public void setServerName(java.lang.String serverName)
Virtual host
Specified by:
setServerName in interface Request

getLookupPath

public java.lang.String getLookupPath()

setLookupPath

public void setLookupPath(java.lang.String l)

getParameter

public java.lang.String getParameter(java.lang.String name)
Specified by:
getParameter in interface Request

getParameterValues

public java.lang.String[] getParameterValues(java.lang.String name)
Description copied from interface: Request
Set query string - will be called by forward
Specified by:
getParameterValues in interface Request

getParameterNames

public java.util.Enumeration getParameterNames()
Specified by:
getParameterNames in interface Request

getAuthType

public java.lang.String getAuthType()
Specified by:
getAuthType in interface Request

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Specified by:
getCharacterEncoding in interface Request

getContentLength

public int getContentLength()
Specified by:
getContentLength in interface Request

getContentType

public java.lang.String getContentType()
Specified by:
getContentType in interface Request

setPathTranslated

public void setPathTranslated(java.lang.String s)
All adapters that know the PT needs to call this method, in order to set pathTranslatedIsSet, otherwise tomcat will try to compute it again
Specified by:
setPathTranslated in interface Request

getPathTranslated

public java.lang.String getPathTranslated()
Not so usefull - it return the path translated for a URL relative the the context, i.e. different from what PATH_TRANSLATED does. Avoid using it.
Specified by:
getPathTranslated in interface Request

getPathInfo

public java.lang.String getPathInfo()
Description copied from interface: Request
Path Info - set be mappers or from adapter
Specified by:
getPathInfo in interface Request

setRemoteUser

public void setRemoteUser(java.lang.String s)
Specified by:
setRemoteUser in interface Request

getRemoteUser

public java.lang.String getRemoteUser()
Specified by:
getRemoteUser in interface Request

isSecure

public boolean isSecure()
Specified by:
isSecure in interface Request

setUserPrincipal

public void setUserPrincipal(java.security.Principal p)
Specified by:
setUserPrincipal in interface Request

getUserPrincipal

public java.security.Principal getUserPrincipal()
Return the principal - the adapter will set it
Specified by:
getUserPrincipal in interface Request

setRequiredRoles

public void setRequiredRoles(java.lang.String[] roles)
Specified by:
setRequiredRoles in interface Request

getRequiredRoles

public java.lang.String[] getRequiredRoles()
Description copied from interface: Request
If this request is subject to a security constraint. A better way would be to have a "merge" mechanism to add all properties to the container ( like in Apache), but until this is implemented we'll just keep the fields in request.
Specified by:
getRequiredRoles in interface Request

setUserRoles

public void setUserRoles(java.lang.String[] roles)
Specified by:
setUserRoles in interface Request

getUserRoles

public java.lang.String[] getUserRoles()
Specified by:
getUserRoles in interface Request

isUserInRole

public boolean isUserInRole(java.lang.String role)
Specified by:
isUserInRole in interface Request

getServletPath

public java.lang.String getServletPath()
Specified by:
getServletPath in interface Request

getFacade

public javax.servlet.http.HttpServletRequest getFacade()
Description copied from interface: Request
One-to-One with Facade
Specified by:
getFacade in interface Request

getContext

public Context getContext()
Specified by:
getContext in interface Request

setResponse

public void setResponse(Response response)
Specified by:
setResponse in interface Request

getResponse

public Response getResponse()
Description copied from interface: Request
One-to-One with Response
Specified by:
getResponse in interface Request

getJvmRoute

public java.lang.String getJvmRoute()
Specified by:
getJvmRoute in interface Request

setJvmRoute

public void setJvmRoute(java.lang.String jvmRoute)
Specified by:
setJvmRoute in interface Request

getRequestedSessionId

public java.lang.String getRequestedSessionId()
Specified by:
getRequestedSessionId in interface Request

setRequestedSessionId

public void setRequestedSessionId(java.lang.String reqSessionId)
Specified by:
setRequestedSessionId in interface Request

getSessionIdSource

public java.lang.String getSessionIdSource()
Description copied from interface: Request
Get the source of the session Id.
Specified by:
getSessionIdSource in interface Request

setSessionIdSource

public void setSessionIdSource(java.lang.String s)
Specified by:
setSessionIdSource in interface Request

setSession

public void setSession(javax.servlet.http.HttpSession serverSession)
Specified by:
setSession in interface Request

getSession

public javax.servlet.http.HttpSession getSession(boolean create)
Specified by:
getSession in interface Request

getCookieCount

public int getCookieCount()
Specified by:
getCookieCount in interface Request

getCookie

public javax.servlet.http.Cookie getCookie(int idx)
Specified by:
getCookie in interface Request

getCookies

public javax.servlet.http.Cookie[] getCookies()

getWrapper

public ServletWrapper getWrapper()
Description copied from interface: Request
Wrapper - the servlet that will execute the request Similar with "handler" in Apache.
Specified by:
getWrapper in interface Request

setWrapper

public void setWrapper(ServletWrapper handler)
Specified by:
setWrapper in interface Request

getContainer

public Container getContainer()
Specified by:
getContainer in interface Request

setContainer

public void setContainer(Container container)
Specified by:
setContainer in interface Request

getMappedPath

public java.lang.String getMappedPath()
The file - result of mapping the request ( using aliases and other mapping rules. Usefull only for static resources.

setMappedPath

public void setMappedPath(java.lang.String m)

setRequestURI

public void setRequestURI(java.lang.String r)
Specified by:
setRequestURI in interface Request

setParameters

public void setParameters(java.util.Hashtable h)
Specified by:
setParameters in interface Request

getParameters

public java.util.Hashtable getParameters()
Specified by:
getParameters in interface Request

setContentLength

public void setContentLength(int len)
Specified by:
setContentLength in interface Request

setContentType

public void setContentType(java.lang.String type)
Specified by:
setContentType in interface Request

setCharEncoding

public void setCharEncoding(java.lang.String enc)
Specified by:
setCharEncoding in interface Request

setAuthType

public void setAuthType(java.lang.String authType)
Specified by:
setAuthType in interface Request

setPathInfo

public void setPathInfo(java.lang.String pathInfo)
Specified by:
setPathInfo in interface Request

setQueryString

public void setQueryString(java.lang.String queryString)
Set query string - will be called by forward
Specified by:
setQueryString in interface Request

setServletPath

public void setServletPath(java.lang.String servletPath)
Description copied from interface: Request
Servlet Path
Specified by:
setServletPath in interface Request

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Specified by:
getAttribute in interface Request

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Specified by:
setAttribute in interface Request

removeAttribute

public void removeAttribute(java.lang.String name)
Specified by:
removeAttribute in interface Request

getAttributeNames

public java.util.Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface Request

getParent

public Request getParent()
If this is a sub-request, return the parent
Specified by:
getParent in interface Request

setParent

public void setParent(Request req)
Specified by:
setParent in interface Request

getChild

public Request getChild()
During include, a sub-request will be created. This represents the current included request
Specified by:
getChild in interface Request

setChild

public void setChild(Request req)
Specified by:
setChild in interface Request

getTop

public Request getTop()
This is the top request ( for a sub-request )
Specified by:
getTop in interface Request

getHeaders

public java.util.Enumeration getHeaders(java.lang.String name)
Specified by:
getHeaders in interface Request

getReader

public java.io.BufferedReader getReader()
                                 throws java.io.IOException
Specified by:
getReader in interface Request

recycle

public void recycle()
Description copied from interface: Request
Support for "pools"
Specified by:
recycle in interface Request

getMimeHeaders

public org.apache.tomcat.util.MimeHeaders getMimeHeaders()
Specified by:
getMimeHeaders in interface Request

getHeader

public java.lang.String getHeader(java.lang.String name)
Specified by:
getHeader in interface Request

getHeaderNames

public java.util.Enumeration getHeaderNames()
Specified by:
getHeaderNames in interface Request

getInputBuffer

public org.apache.tomcat.util.ByteBuffer getInputBuffer()
Specified by:
getInputBuffer in interface Request

setInputBuffer

public void setInputBuffer(org.apache.tomcat.util.ByteBuffer buf)
Specified by:
setInputBuffer in interface Request

getInputStream

public javax.servlet.ServletInputStream getInputStream()
                                                throws java.io.IOException
Specified by:
getInputStream in interface Request

getServerPort

public int getServerPort()
Specified by:
getServerPort in interface Request

getRemoteAddr

public java.lang.String getRemoteAddr()
Specified by:
getRemoteAddr in interface Request

getRemoteHost

public java.lang.String getRemoteHost()
Description copied from interface: Request
Expensive - should be implemented as a callback where possible!
Specified by:
getRemoteHost in interface Request

doRead

public int doRead(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Fill in the buffer. This method is probably easier to implement than previous. This method should only be called from SerlvetInputStream implementations. No need to implement it if your adapter implements ServletInputStream.
Specified by:
doRead in interface Request

doRead

public int doRead()
           throws java.io.IOException

getServletPrefix

public java.lang.String getServletPrefix()

setScheme

public void setScheme(java.lang.String scheme)
Specified by:
setScheme in interface Request

setMethod

public void setMethod(java.lang.String method)
Specified by:
setMethod in interface Request

setProtocol

public void setProtocol(java.lang.String protocol)
Specified by:
setProtocol in interface Request

setMimeHeaders

public void setMimeHeaders(org.apache.tomcat.util.MimeHeaders headers)

setBody

public void setBody(java.lang.StringBuffer body)

setServerPort

public void setServerPort(int serverPort)
Specified by:
setServerPort in interface Request

setRemoteAddr

public void setRemoteAddr(java.lang.String remoteAddr)
Specified by:
setRemoteAddr in interface Request

setRemoteHost

public void setRemoteHost(java.lang.String remoteHost)
Specified by:
setRemoteHost in interface Request

getLocalHost

public java.lang.String getLocalHost()
Specified by:
getLocalHost in interface Request

setLocalHost

public void setLocalHost(java.lang.String host)
Specified by:
setLocalHost in interface Request

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toStringDebug

public java.lang.String toStringDebug()

setAccount

public void setAccount(int pos,
                       long value)

getAccount

public long getAccount(int pos)

setNote

public void setNote(int pos,
                    java.lang.Object value)
Description copied from interface: Request
Add a per/request internal attribute. We keep internal attributes in a separate space to prevent servlets from accessing them. We also use indexed access for speed ( as oposed to hashtable lookups ). Get an Id from ContextManager.
Specified by:
setNote in interface Request

getNote

public java.lang.Object getNote(int pos)
Specified by:
getNote in interface Request


Copyright © 2000 Apache Software Foundation. All Rights Reserved.