Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mortbay.jetty
Class Request

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

Direct Known Subclasses:
  Ajp13Request

    public class Request

extends Object

Jetty Request.

Implements `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

Constructor Summary
`Request(HttpConnection connection)`

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

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

Constructor Detail

### Request

    public Request(HttpConnection connection)

Method Detail

### recycle

    protected void recycle()

### getTimeStampStr

    public String getTimeStampStr()

  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 Object getAttribute(String name)

### getAttributeNames

    public Enumeration getAttributeNames()

### getAuthType

    public String getAuthType()

### getCharacterEncoding

    public String getCharacterEncoding()

### getContentLength

    public int getContentLength()

### getContentType

    public String getContentType()

### setContentType

    public void setContentType(String contentType)

### getContextPath

    public String getContextPath()

### getCookies

    public Cookie[] getCookies()

### getDateHeader

    public long getDateHeader(String name)

### getHeader

    public String getHeader(String name)

### getHeaderNames

    public Enumeration getHeaderNames()

### getHeaders

    public Enumeration getHeaders(String name)

### getInputStream

    public ServletInputStream getInputStream()
                                      throws IOException

  Throws:
    `IOException`

### getIntHeader

    public int getIntHeader(String name)

### getLocalAddr

    public String getLocalAddr()

### getLocale

    public Locale getLocale()

### getLocales

    public Enumeration getLocales()

### getLocalName

    public String getLocalName()

### getLocalPort

    public int getLocalPort()

### getMethod

    public String getMethod()

### getParameter

    public String getParameter(String name)

### getParameterMap

    public Map getParameterMap()

### getParameterNames

    public Enumeration getParameterNames()

### getParameterValues

    public String[] getParameterValues(String name)

### getPathInfo

    public String getPathInfo()

### getPathTranslated

    public String getPathTranslated()

### getProtocol

    public String getProtocol()

### getReader

    public BufferedReader getReader()
                             throws IOException

  Throws:
    `IOException`

### getRealPath

    public String getRealPath(String path)

### getRemoteAddr

    public String getRemoteAddr()

### getRemoteHost

    public String getRemoteHost()

### getRemotePort

    public int getRemotePort()

### getRemoteUser

    public String getRemoteUser()

### getRequestDispatcher

    public RequestDispatcher getRequestDispatcher(String path)

### getRequestedSessionId

    public String getRequestedSessionId()

### getRequestURI

    public String getRequestURI()

### getRequestURL

    public StringBuffer getRequestURL()

### getScheme

    public String getScheme()

### getServerName

    public String getServerName()

### getServerPort

    public int getServerPort()

### getServletPath

    public String getServletPath()

### getServletName

    public String getServletName()

### getSession

    public HttpSession getSession()

### getSession

    public HttpSession getSession(boolean create)

### getUserPrincipal

    public Principal getUserPrincipal()

### getQueryString

    public String getQueryString()

### isRequestedSessionIdFromCookie

    public boolean isRequestedSessionIdFromCookie()

### isRequestedSessionIdFromUrl

    public boolean isRequestedSessionIdFromUrl()

### isRequestedSessionIdFromURL

    public boolean isRequestedSessionIdFromURL()

### isRequestedSessionIdValid

    public boolean isRequestedSessionIdValid()

### isSecure

    public boolean isSecure()

### isUserInRole

    public boolean isUserInRole(String role)

### removeAttribute

    public void removeAttribute(String name)

### setAttribute

    public void setAttribute(String name,
                             Object value)

### setCharacterEncoding

    public void setCharacterEncoding(String encoding)
                              throws UnsupportedEncodingException

  Throws:
    `UnsupportedEncodingException`

### setCharacterEncodingUnchecked

    public void setCharacterEncodingUnchecked(String encoding)

### setServerName

    public void setServerName(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(String authType)

  Parameters:
    `authType` - The authType to set.

### setCookies

    public void setCookies(Cookie[] cookies)

  Parameters:
    `cookies` - The cookies to set.

### setMethod

    public void setMethod(String method)

  Parameters:
    `method` - The method to set.

### setPathInfo

    public void setPathInfo(String pathInfo)

  Parameters:
    `pathInfo` - The pathInfo to set.

### setProtocol

    public void setProtocol(String protocol)

  Parameters:
    `protocol` - The protocol to set.

### setRequestedSessionId

    public void setRequestedSessionId(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(HttpSession session)

  Parameters:
    `session` - The session to set.

### setScheme

    public void setScheme(String scheme)

  Parameters:
    `scheme` - The scheme to set.

### setQueryString

    public void setQueryString(String queryString)

  Parameters:
    `queryString` - The queryString to set.

### setRequestURI

    public void setRequestURI(String requestURI)

  Parameters:
    `requestURI` - The requestURI to set.

### setContextPath

    public void setContextPath(String contextPath)

  Sets the "context path" for this request

  See Also:
    `HttpServletRequest#getContextPath`

### setServletPath

    public void setServletPath(String servletPath)

  Parameters:
    `servletPath` - The servletPath to set.

### setServletName

    public void setServletName(String name)

  Parameters:
    `name` - The servletName to set.

### setUserPrincipal

    public void setUserPrincipal(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 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 String toString()

  Overrides:
    `toString` in class `Object`

### getRequest

    public static Request getRequest(HttpServletRequest request)

### addEventListener

    public void addEventListener(EventListener listener)

### removeEventListener

    public void removeEventListener(EventListener listener)

### saveNewSession

    public void saveNewSession(Object key,
                               HttpSession session)

### recoverNewSession

    public HttpSession recoverNewSession(Object key)

### getUserRealm

    public UserRealm getUserRealm()

  Returns:
    Returns the userRealm.

### setUserRealm

    public void setUserRealm(UserRealm userRealm)

  Parameters:
    `userRealm` - The userRealm to set.

### getQueryEncoding

    public String getQueryEncoding()

### setQueryEncoding

    public void setQueryEncoding(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(Map map)

### getRoleMap

    public Map getRoleMap()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2007 Mort Bay Consulting. All Rights Reserved.