## org.mortbay.jetty
Class Request

    java.lang.Object
      org.mortbay.jetty.Request

All Implemented Interfaces:
  javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest

Direct Known Subclasses:
  Ajp13Request

    public class Request

extends java.lang.Object
implements javax.servlet.http.HttpServletRequest

Jetty Request.

Implements `javax.servlet.HttpServletRequest` from the `javax.servlet` package.

The standard interface of mostly getters, is extended with setters so that the request is mutable by the handlers that it is passed to. This allows the request object to be as lightweight as possible and not actually implement any significant behaviour. For example

- The `getContextPath` method will return null, until the requeset has been passed to a `ContextHandler` which matches the `getPathInfo` with a context path and calls `setContextPath` as a result.
- the HTTP session methods will all return null sessions until such time as a request has been passed to a `SessionHandler` which checks for session cookies and enables the ability to create new sessions.
- The `getServletPath` method will return null until the request has been passed to a `ServletHandler` and the pathInfo matched against the servlet URL patterns and `setServletPath` called as a result.

A request instance is created for each `HttpConnection` accepted by the server and recycled for each HTTP request received via that connection. An effort is made to avoid reparsing headers and cookies that are likely to be the same for requests from the same connection.

Author:
  gregw

Field Summary

Fields inherited from interface javax.servlet.http.HttpServletRequest
`BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH`

Constructor Summary
`Request()`
`Request(HttpConnection connection)`

Method Summary
`void` `addEventListener(java.util.EventListener listener)`
`java.lang.Object` `getAttribute(java.lang.String name)`
`java.util.Enumeration` `getAttributeNames()`
`Attributes` `getAttributes()`
`java.lang.String` `getAuthType()`
`java.lang.String` `getCharacterEncoding()`
`HttpConnection` `getConnection()`
`int` `getContentLength()`
`long` `getContentRead()`
`java.lang.String` `getContentType()`
`ContextHandler.SContext` `getContext()`
`java.lang.String` `getContextPath()`
`Continuation` `getContinuation()`
`Continuation` `getContinuation(boolean create)`
`javax.servlet.http.Cookie[]` `getCookies()`
`long` `getDateHeader(java.lang.String name)`
`java.lang.String` `getHeader(java.lang.String name)`
`java.util.Enumeration` `getHeaderNames()`
`java.util.Enumeration` `getHeaders(java.lang.String name)`
`int` `getInputState()`
`javax.servlet.ServletInputStream` `getInputStream()`
`int` `getIntHeader(java.lang.String name)`
`java.lang.String` `getLocalAddr()`
`java.util.Locale` `getLocale()`
`java.util.Enumeration` `getLocales()`
`java.lang.String` `getLocalName()`
`int` `getLocalPort()`
`java.lang.String` `getMethod()`
`java.lang.String` `getParameter(java.lang.String name)`
`java.util.Map` `getParameterMap()`
`java.util.Enumeration` `getParameterNames()`
`MultiMap` `getParameters()`
`java.lang.String[]` `getParameterValues(java.lang.String name)`
`java.lang.String` `getPathInfo()`
`java.lang.String` `getPathTranslated()`
`java.lang.String` `getProtocol()`
`java.lang.String` `getQueryEncoding()`
`java.lang.String` `getQueryString()`
`java.io.BufferedReader` `getReader()`
`java.lang.String` `getRealPath(java.lang.String path)`
`java.lang.String` `getRemoteAddr()`
`java.lang.String` `getRemoteHost()`
`int` `getRemotePort()`
`java.lang.String` `getRemoteUser()`
`static Request` `getRequest(javax.servlet.http.HttpServletRequest request)`
`javax.servlet.RequestDispatcher` `getRequestDispatcher(java.lang.String path)`
`java.lang.String` `getRequestedSessionId()`
`java.lang.String` `getRequestURI()`
`java.lang.StringBuffer` `getRequestURL()`
`java.util.Map` `getRoleMap()`
`java.lang.StringBuffer` `getRootURL()` Reconstructs the URL the client used to make the request.
`java.lang.String` `getScheme()`
`java.lang.String` `getServerName()`
`int` `getServerPort()`
`javax.servlet.ServletContext` `getServletContext()`
`java.lang.String` `getServletName()`
`java.lang.String` `getServletPath()`
`javax.servlet.ServletResponse` `getServletResponse()`
`javax.servlet.http.HttpSession` `getSession()`
`javax.servlet.http.HttpSession` `getSession(boolean create)`
`SessionManager` `getSessionManager()`
`long` `getTimeStamp()` Get Request TimeStamp
`Buffer` `getTimeStampBuffer()` Get Request TimeStamp
`HttpURI` `getUri()`
`java.security.Principal` `getUserPrincipal()`
`UserRealm` `getUserRealm()`
`boolean` `isHandled()`
`boolean` `isRequestedSessionIdFromCookie()`
`boolean` `isRequestedSessionIdFromUrl()`
`boolean` `isRequestedSessionIdFromURL()`
`boolean` `isRequestedSessionIdValid()`
`boolean` `isSecure()`
`boolean` `isUserInRole(java.lang.String role)`
`javax.servlet.http.HttpSession` `recoverNewSession(java.lang.Object key)`
`protected void` `recycle()`
`void` `removeAttribute(java.lang.String name)`
`void` `removeEventListener(java.util.EventListener listener)`
`void` `saveNewSession(java.lang.Object key, javax.servlet.http.HttpSession session)`
`void` `setAttribute(java.lang.String name, java.lang.Object value)`
`void` `setAttributes(Attributes attributes)`
`void` `setAuthType(java.lang.String authType)`
`void` `setCharacterEncoding(java.lang.String encoding)`
`void` `setCharacterEncodingUnchecked(java.lang.String encoding)`
`protected void` `setConnection(HttpConnection connection)`
`void` `setContentType(java.lang.String contentType)`
`void` `setContext(ContextHandler.SContext context)`
`void` `setContextPath(java.lang.String contextPath)` Sets the "context path" for this request
`void` `setCookies(javax.servlet.http.Cookie[] cookies)`
`void` `setHandled(boolean h)`
`void` `setMethod(java.lang.String method)`
`void` `setParameters(MultiMap parameters)`
`void` `setPathInfo(java.lang.String pathInfo)`
`void` `setProtocol(java.lang.String protocol)`
`void` `setQueryEncoding(java.lang.String queryEncoding)` Set the character encoding used for the query string.
`void` `setQueryString(java.lang.String queryString)`
`void` `setRemoteAddr(java.lang.String addr)`
`void` `setRemoteHost(java.lang.String host)`
`void` `setRequestedSessionId(java.lang.String requestedSessionId)`
`void` `setRequestedSessionIdFromCookie(boolean requestedSessionIdCookie)`
`void` `setRequestListeners(java.lang.Object requestListeners)`
`void` `setRequestURI(java.lang.String requestURI)`
`void` `setRoleMap(java.util.Map map)`
`void` `setScheme(java.lang.String scheme)`
`void` `setServerName(java.lang.String host)`
`void` `setServerPort(int port)`
`void` `setServletName(java.lang.String name)`
`void` `setServletPath(java.lang.String servletPath)`
`void` `setSession(javax.servlet.http.HttpSession session)`
`void` `setSessionManager(SessionManager sessionManager)`
`void` `setTimeStamp(long ts)`
`void` `setUri(HttpURI uri)`
`void` `setUserPrincipal(java.security.Principal userPrincipal)`
`void` `setUserRealm(UserRealm userRealm)`
`java.lang.Object` `takeRequestListeners()`
`java.lang.String` `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Request

    public Request()

### Request

    public Request(HttpConnection connection)

Method Detail

### setConnection

    protected void setConnection(HttpConnection connection)

### recycle

    protected void recycle()

### getTimeStampBuffer

    public Buffer getTimeStampBuffer()

  Get Request TimeStamp

  Returns:
    The time that the request was received.

### getTimeStamp

    public long getTimeStamp()

  Get Request TimeStamp

  Returns:
    The time that the request was received.

### setTimeStamp

    public void setTimeStamp(long ts)

### isHandled

    public boolean isHandled()

### setHandled

    public void setHandled(boolean h)

### getAttribute

    public java.lang.Object getAttribute(java.lang.String name)

  Specified by:
    `getAttribute` in interface `javax.servlet.ServletRequest`

### getAttributeNames

    public java.util.Enumeration getAttributeNames()

  Specified by:
    `getAttributeNames` in interface `javax.servlet.ServletRequest`

### getAuthType

    public java.lang.String getAuthType()

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

### getCharacterEncoding

    public java.lang.String getCharacterEncoding()

  Specified by:
    `getCharacterEncoding` in interface `javax.servlet.ServletRequest`

### getContentRead

    public long getContentRead()

### getContentLength

    public int getContentLength()

  Specified by:
    `getContentLength` in interface `javax.servlet.ServletRequest`

### getContentType

    public java.lang.String getContentType()

  Specified by:
    `getContentType` in interface `javax.servlet.ServletRequest`

### setContentType

    public void setContentType(java.lang.String contentType)

### getContextPath

    public java.lang.String getContextPath()

  Specified by:
    `getContextPath` in interface `javax.servlet.http.HttpServletRequest`

### getCookies

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

  Specified by:
    `getCookies` in interface `javax.servlet.http.HttpServletRequest`

### getDateHeader

    public long getDateHeader(java.lang.String name)

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

### getHeader

    public java.lang.String getHeader(java.lang.String name)

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

### getHeaderNames

    public java.util.Enumeration getHeaderNames()

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

### getHeaders

    public java.util.Enumeration getHeaders(java.lang.String name)

  Specified by:
    `getHeaders` in interface `javax.servlet.http.HttpServletRequest`

### getInputStream

    public javax.servlet.ServletInputStream getInputStream()
                                                    throws java.io.IOException

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

### getIntHeader

    public int getIntHeader(java.lang.String name)

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

### getLocalAddr

    public java.lang.String getLocalAddr()

  Specified by:
    `getLocalAddr` in interface `javax.servlet.ServletRequest`

### getLocale

    public java.util.Locale getLocale()

  Specified by:
    `getLocale` in interface `javax.servlet.ServletRequest`

### getLocales

    public java.util.Enumeration getLocales()

  Specified by:
    `getLocales` 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`

### getMethod

    public java.lang.String getMethod()

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

### getParameter

    public java.lang.String getParameter(java.lang.String name)

  Specified by:
    `getParameter` in interface `javax.servlet.ServletRequest`

### getParameterMap

    public java.util.Map getParameterMap()

  Specified by:
    `getParameterMap` in interface `javax.servlet.ServletRequest`

### getParameterNames

    public java.util.Enumeration getParameterNames()

  Specified by:
    `getParameterNames` in interface `javax.servlet.ServletRequest`

### getParameterValues

    public java.lang.String[] getParameterValues(java.lang.String name)

  Specified by:
    `getParameterValues` in interface `javax.servlet.ServletRequest`

### getPathInfo

    public java.lang.String getPathInfo()

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

### getPathTranslated

    public java.lang.String getPathTranslated()

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

### getProtocol

    public java.lang.String getProtocol()

  Specified by:
    `getProtocol` in interface `javax.servlet.ServletRequest`

### getReader

    public java.io.BufferedReader getReader()
                                     throws java.io.IOException

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

### getRealPath

    public java.lang.String getRealPath(java.lang.String path)

  Specified by:
    `getRealPath` in interface `javax.servlet.ServletRequest`

### getRemoteAddr

    public java.lang.String getRemoteAddr()

  Specified by:
    `getRemoteAddr` in interface `javax.servlet.ServletRequest`

### getRemoteHost

    public java.lang.String getRemoteHost()

  Specified by:
    `getRemoteHost` in interface `javax.servlet.ServletRequest`

### getRemotePort

    public int getRemotePort()

  Specified by:
    `getRemotePort` in interface `javax.servlet.ServletRequest`

### getRemoteUser

    public java.lang.String getRemoteUser()

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

### getRequestDispatcher

    public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)

  Specified by:
    `getRequestDispatcher` in interface `javax.servlet.ServletRequest`

### getRequestedSessionId

    public java.lang.String getRequestedSessionId()

  Specified by:
    `getRequestedSessionId` in interface `javax.servlet.http.HttpServletRequest`

### getRequestURI

    public java.lang.String getRequestURI()

  Specified by:
    `getRequestURI` in interface `javax.servlet.http.HttpServletRequest`

### getRequestURL

    public java.lang.StringBuffer getRequestURL()

  Specified by:
    `getRequestURL` in interface `javax.servlet.http.HttpServletRequest`

### getScheme

    public java.lang.String getScheme()

  Specified by:
    `getScheme` in interface `javax.servlet.ServletRequest`

### getServerName

    public java.lang.String getServerName()

  Specified by:
    `getServerName` in interface `javax.servlet.ServletRequest`

### getServerPort

    public int getServerPort()

  Specified by:
    `getServerPort` in interface `javax.servlet.ServletRequest`

### getServletPath

    public java.lang.String getServletPath()

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

### getServletName

    public java.lang.String getServletName()

### getSession

    public javax.servlet.http.HttpSession getSession()

  Specified by:
    `getSession` in interface `javax.servlet.http.HttpServletRequest`

### getSession

    public javax.servlet.http.HttpSession getSession(boolean create)

  Specified by:
    `getSession` in interface `javax.servlet.http.HttpServletRequest`

### getUserPrincipal

    public java.security.Principal getUserPrincipal()

  Specified by:
    `getUserPrincipal` in interface `javax.servlet.http.HttpServletRequest`

### getQueryString

    public java.lang.String getQueryString()

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

### isRequestedSessionIdFromCookie

    public boolean isRequestedSessionIdFromCookie()

  Specified by:
    `isRequestedSessionIdFromCookie` in interface `javax.servlet.http.HttpServletRequest`

### isRequestedSessionIdFromUrl

    public boolean isRequestedSessionIdFromUrl()

  Specified by:
    `isRequestedSessionIdFromUrl` in interface `javax.servlet.http.HttpServletRequest`

### isRequestedSessionIdFromURL

    public boolean isRequestedSessionIdFromURL()

  Specified by:
    `isRequestedSessionIdFromURL` in interface `javax.servlet.http.HttpServletRequest`

### isRequestedSessionIdValid

    public boolean isRequestedSessionIdValid()

  Specified by:
    `isRequestedSessionIdValid` in interface `javax.servlet.http.HttpServletRequest`

### isSecure

    public boolean isSecure()

  Specified by:
    `isSecure` in interface `javax.servlet.ServletRequest`

### isUserInRole

    public boolean isUserInRole(java.lang.String role)

  Specified by:
    `isUserInRole` in interface `javax.servlet.http.HttpServletRequest`

### removeAttribute

    public void removeAttribute(java.lang.String name)

  Specified by:
    `removeAttribute` in interface `javax.servlet.ServletRequest`

### setAttribute

    public void setAttribute(java.lang.String name,
                             java.lang.Object value)

  Specified by:
    `setAttribute` in interface `javax.servlet.ServletRequest`

### setCharacterEncoding

    public void setCharacterEncoding(java.lang.String encoding)
                              throws java.io.UnsupportedEncodingException

  Specified by:
    `setCharacterEncoding` in interface `javax.servlet.ServletRequest`
  Throws:
    `java.io.UnsupportedEncodingException`

### setCharacterEncodingUnchecked

    public void setCharacterEncodingUnchecked(java.lang.String encoding)

### setServerName

    public void setServerName(java.lang.String host)

  Parameters:
    `host` - The host to set.

### setServerPort

    public void setServerPort(int port)

  Parameters:
    `port` - The port to set.

### setRemoteAddr

    public void setRemoteAddr(java.lang.String addr)

  Parameters:
    `addr` - The address to set.

### setRemoteHost

    public void setRemoteHost(java.lang.String host)

  Parameters:
    `host` - The host to set.

### getUri

    public HttpURI getUri()

  Returns:
    Returns the uri.

### setUri

    public void setUri(HttpURI uri)

  Parameters:
    `uri` - The uri to set.

### getConnection

    public HttpConnection getConnection()

  Returns:
    Returns the connection.

### getInputState

    public int getInputState()

  Returns:
    Returns the inputState.

### setAuthType

    public void setAuthType(java.lang.String authType)

  Parameters:
    `authType` - The authType to set.

### setCookies

    public void setCookies(javax.servlet.http.Cookie[] cookies)

  Parameters:
    `cookies` - The cookies to set.

### setMethod

    public void setMethod(java.lang.String method)

  Parameters:
    `method` - The method to set.

### setPathInfo

    public void setPathInfo(java.lang.String pathInfo)

  Parameters:
    `pathInfo` - The pathInfo to set.

### setProtocol

    public void setProtocol(java.lang.String protocol)

  Parameters:
    `protocol` - The protocol to set.

### setRequestedSessionId

    public void setRequestedSessionId(java.lang.String requestedSessionId)

  Parameters:
    `requestedSessionId` - The requestedSessionId to set.

### getSessionManager

    public SessionManager getSessionManager()

  Returns:
    Returns the sessionManager.

### setSessionManager

    public void setSessionManager(SessionManager sessionManager)

  Parameters:
    `sessionManager` - The sessionManager to set.

### setRequestedSessionIdFromCookie

    public void setRequestedSessionIdFromCookie(boolean requestedSessionIdCookie)

  Parameters:
    `requestedSessionIdCookie` - The requestedSessionIdCookie to set.

### setSession

    public void setSession(javax.servlet.http.HttpSession session)

  Parameters:
    `session` - The session to set.

### setScheme

    public void setScheme(java.lang.String scheme)

  Parameters:
    `scheme` - The scheme to set.

### setQueryString

    public void setQueryString(java.lang.String queryString)

  Parameters:
    `queryString` - The queryString to set.

### setRequestURI

    public void setRequestURI(java.lang.String requestURI)

  Parameters:
    `requestURI` - The requestURI to set.

### setContextPath

    public void setContextPath(java.lang.String contextPath)

  Sets the "context path" for this request

  See Also:
    `HttpServletRequest.getContextPath()`

### setServletPath

    public void setServletPath(java.lang.String servletPath)

  Parameters:
    `servletPath` - The servletPath to set.

### setServletName

    public void setServletName(java.lang.String name)

  Parameters:
    `name` - The servletName to set.

### setUserPrincipal

    public void setUserPrincipal(java.security.Principal userPrincipal)

  Parameters:
    `userPrincipal` - The userPrincipal to set.

### setContext

    public void setContext(ContextHandler.SContext context)

  Parameters:
    `context` -

### getContext

    public ContextHandler.SContext getContext()

  Returns:
    The current `context` used for this request, or `null` if `setContext(org.mortbay.jetty.handler.ContextHandler.SContext)` has not yet been called.

### getRootURL

    public java.lang.StringBuffer getRootURL()

  Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and, but it does not include a path.

  Because this method returns a `StringBuffer`, not a string, you can modify the URL easily, for example, to append path and query parameters. This method is useful for creating redirect messages and for reporting errors.

  Returns:
    "scheme://host:port"

### getAttributes

    public Attributes getAttributes()

### setAttributes

    public void setAttributes(Attributes attributes)

### getContinuation

    public Continuation getContinuation()

### getContinuation

    public Continuation getContinuation(boolean create)

### getParameters

    public MultiMap getParameters()

  Returns:
    Returns the parameters.

### setParameters

    public void setParameters(MultiMap parameters)

  Parameters:
    `parameters` - The parameters to set.

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### getRequest

    public static Request getRequest(javax.servlet.http.HttpServletRequest request)

### addEventListener

    public void addEventListener(java.util.EventListener listener)

### removeEventListener

    public void removeEventListener(java.util.EventListener listener)

### setRequestListeners

    public void setRequestListeners(java.lang.Object requestListeners)

  Parameters:
    `requestListeners` - `LazyList` of `ServletRequestListener`s

### takeRequestListeners

    public java.lang.Object takeRequestListeners()

  Returns:
    `LazyList` of `ServletRequestListener`s

### saveNewSession

    public void saveNewSession(java.lang.Object key,
                               javax.servlet.http.HttpSession session)

### recoverNewSession

    public javax.servlet.http.HttpSession recoverNewSession(java.lang.Object key)

### getUserRealm

    public UserRealm getUserRealm()

  Returns:
    Returns the userRealm.

### setUserRealm

    public void setUserRealm(UserRealm userRealm)

  Parameters:
    `userRealm` - The userRealm to set.

### getQueryEncoding

    public java.lang.String getQueryEncoding()

### setQueryEncoding

    public void setQueryEncoding(java.lang.String queryEncoding)

  Set the character encoding used for the query string. This call will effect the return of getQueryString and getParamaters. It must be called before any geParameter methods. The request attribute "org.mortbay.jetty.Request.queryEncoding" may be set as an alternate method of calling setQueryEncoding.

  Parameters:
    `queryEncoding` -

### setRoleMap

    public void setRoleMap(java.util.Map map)

### getRoleMap

    public java.util.Map getRoleMap()

### getServletContext

    public javax.servlet.ServletContext getServletContext()

### getServletResponse

    public javax.servlet.ServletResponse getServletResponse()

Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.